您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
开启注册登陆功能(解决laravel安装Breeze后没有注册、登录功能)
发布时间:2024-10-27 11:53:45编辑:雪饮阅读()
-
安装
首先,您应该创建新的 Laravel 应用程序,配置数据库,然后运行数据库迁移.创建新的 Laravel 应用程序后,您可以使用 Composer 安装 Laravel Breeze:
由于我们是以docker的方式安装的laravel,所以我们的应该如
./vendor/bin/sail composer require laravel/breeze --dev
Breeze & Blade
After Composer has installed the Laravel Breeze package, you may run the Artisan command. This command publishes the authentication views, routes, controllers, and other resources to your application. Laravel Breeze publishes all of its code to your application so that you have full control and visibility over its features and implementation.breeze:install
The default Breeze "stack" is the Blade stack, which utilizes simple Blade templates to render your application's frontend. The Blade stack may be installed by invoking the command with no other additional arguments. After Breeze's scaffolding is installed, you should also compile your application's frontend assets:breeze:install
php artisan breeze:install
php artisan migrate
npm install
npm run dev
Next, you may navigate to your application's or URLs in your web browser. All of Breeze's routes are defined within the file./login/registerroutes/auth.php
微风与刀锋
Composer 安装 Laravel Breeze 包后,您可以运行 Artisan 命令。此命令将身份验证视图、路由、控制器和其他资源发布到您的应用程序。Laravel Breeze 将其所有代码发布到您的应用程序,以便您可以完全控制和查看其功能和实现。breeze:install
默认的 Breeze“堆栈”是 Blade 堆栈,它利用简单的Blade 模板来渲染应用程序的前端。可以通过调用不带其他附加参数的命令来安装 Blade 堆栈。安装 Breeze 的脚手架后,您还应该编译应用程序的前端资产:breeze:install
按照我们的情况应该是
./vendor/bin/sail artisan breeze:install
(有三个选择题,我的选择是第一个选择vue,第二个就是什么暗黑风格,我直接回车给我显示为none,第三个就是单元测试框架我选我们常规的phpunit)
结果这里还报了这么一个错误
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: undefined@undefined
npm error Found: tailwindcss@undefined
npm error node_modules/tailwindcss
npm error dev tailwindcss@"^3.2.1" from the root project
npm error
npm error Could not resolve dependency:
npm error peer tailwindcss@">=3.0.0 || >= 3.0.0-alpha.1 || >= 4.0.0-alpha.20" from @tailwindcss/forms@0.5.9
npm error node_modules/@tailwindcss/forms
npm error dev @tailwindcss/forms@"^0.5.3" from the root project
npm error
npm error Fix the upstream dependency conflict, or retry
npm error this command with --force or --legacy-peer-deps
npm error to accept an incorrect (and potentially broken) dependency resolution.
npm error
npm error
npm error For a full report see:
npm error /home/sail/.npm/_logs/2024-10-26T12_17_04_878Z-eresolve-report.txt
npm error A complete log of this run can be found in: /home/sail/.npm/_logs/2024-10-26T12_17_04_878Z-debug-0.log
尝试淘宝镜像
./vendor/bin/sail npm config set registry https://registry.npm.taobao.org/
尝试新淘宝镜像
./vendor/bin/sail npm config delete registry
./vendor/bin/sail npm config set registry https://registry.npmmirror.com
./vendor/bin/sail npm install tailwindcss@latest --save-dev
尝试华为云镜像
./vendor/bin/sail npm config delete registry
./vendor/bin/sail npm config set registry https://mirrors.huaweicloud.com/repository/npm/
尝试cnpm
./vendor/bin/sail npm install -g cnpm --registry=https://registry.npm.taobao.org/
终于在尝试新淘宝镜像的时候成功,可能也是这个包特别大,增加了204个package,花了6分钟。
那么这次我再来运行下
./vendor/bin/sail artisan breeze:install
然后这次把刚才的那个dark模式也选中(不要回车,要使用空格进行选中)
./vendor/bin/sail artisan migrate
./vendor/bin/sail npm install
./vendor/bin/sail npm run dev
这里又报错:
node:internal/fs/watchers:247
const error = new UVException({
^
Error: ENOSPC: System limit for number of file watchers reached, watch '/var/www/html/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php'
at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
at Object.watch (node:fs:2490:36)
at createFsWatchInstance (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:42779:17)
at setFsWatchListener (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:42826:15)
at NodeFsHandler._watchWithNodeFs (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:42981:14)
at NodeFsHandler._handleFile (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:43045:23)
at NodeFsHandler._addToNodeFs (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:43287:21)
Emitted 'error' event on FSWatcher instance at:
at FSWatcher._handleError (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:44480:10)
at NodeFsHandler._addToNodeFs (file:///var/www/html/node_modules/vite/dist/node/chunks/dep-BWSbWtLw.js:43295:18) {
errno: -28,
syscall: 'watch',
code: 'ENOSPC',
path: '/var/www/html/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php',
filename: '/var/www/html/vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/InlineHTML.php'
}
增加系统监控文件数量限额(在宿主机运行如下命令)
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
那么再次运行
./vendor/bin/sail npm run dev
那么输出结果如
[root@localhost example-app]# ./vendor/bin/sail npm run dev
> dev
> vite
VITE v5.4.10 ready in 254 ms
➜ Local: http://localhost:5173/
➜ Network: http://172.18.0.7:5173/
➜ press h + enter to show help
LARAVEL v11.29.0 plugin v1.0.5
➜ APP_URL: http://localhost
接下来,您可以在 Web 浏览器中导航到您的应用程序或 URL。Breeze 的所有路由都在文件中定义。/login/registerroutes/auth.php
但根据我的虚拟机的真实net网络接入访问的ip则应该访问如
http://192.168.217.130:5173/
图形化的坑
但这个地址虽然对外访问,却并没有那个包含注册与登录入口。
那个入口只能localhost访问,也就是虚拟机内部,虚拟机所属物理机就无法访问了。
所以这就很坑。外部访问的时候不包含注册与登录,我在这里被坑了好久。
但是虚拟机里面centos7太老,有些源导致gnome桌面环境安装老失败。
只能在curl下访问localhost才发现响应的html源文件有区别。但不敢确信。
所以反正centos7太老了,也是该换了,早都想换了,一直舍不得时间,这次就把之前所有想换的一次性换个够本。
用上了centos8.5
CentOS-8.5.2111-x86_64-dvd1.iso
多达10个G的镜像,包含桌面环境。
不过这家伙安装docker以及docker-compose有点麻烦,这里我是直接安装宝塔。
这里发现宝塔上面兼容性系统里面没有centos8,最新兼容性里面有centos9.
我就抱着试试看的心态。我知道宝塔近半年左右时间里的新版本好像都有docker模块,很方便安装,而且感觉docker和docker-compose都没有分别搞,糊里糊涂的全装了,真爽。
当然这里也遇到一些问题,类似这样
Temporary failure resolving 'archive.ubuntu.com'
我的解决如下
systemctl stop firewalld+
setenforce 0
还是不行我就重启。。。。
然后就好了,当然还有另外一个最顽强的问题
Processing triggers for man-db (2.10.2-1)
就这个卡半天最后提示什么npm镜像的一个域名请求不成功
https://registry.npmjs.org/npm
我尝试加在Dockfile中
./vendor/laravel/sail/runtimes/8.3/Dockerfile
给一个上面那个新的淘宝的npm镜像源,好像也是不行。
那我最后直接放大招了。。。
就用这个Clash Verge打开里面的代理=》规则,自己配置的可以外网的规则进行代理就搞定了。不过估计网速慢的时候还是一样,因为那个报好像也挺大的。
那么最后看看我的成果,在虚拟机的localhost用图形化浏览器访问就能看到login和register了。

要停止本次服务所有容器,您只需按 Ctrl + C 即可停止容器的执行。或者,如果容器在后台运行,您可以使用以下命令:stop
关于stop,那么要优雅关闭本次的服务,可以用如
./vendor/bin/sail stop
本期词汇
sail (船)航行;启航
Breeze 微风,和风
Artisan 工匠,技工
Laravel 一个免费的开源 PHP Web 框架
关键字词:注册,登录,laravel