亮暗模式选择
一、框架构成
- Laravel 11
- JetStream
- PHP 8.3
- Mysql_MariaDB_11.3.2
- TailwindCSS 3.4
二、搭建过程
创建Laravel项目
composer create-project --prefer-dist laravel/laravel LuckyPlane安装开发环境助手 laravel-ide-helper 仅适用于开发环境
composer require --dev barryvdh/laravel-ide-helper- 将
["barryvdh/laravel-ide-helper"]添加到composer.json文件的extra.laravel.dont-discover中 - 将
Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,添加到config/app.php文件的providers数组中。 ~Laravel11默认没有这个配置,需要手动添加~ - 在
AppServiceProvider文件里使用register()方法添加尽在本地环境时自动加载IdeHelperServiceProvider代码 - 执行
php artisan ide-helper:generate生成_ide_helper.php文件 - 执行
php artisan ide-helper:meta生成_ide_helper_models.php文件 - 执行
php artisan ide-helper:models生成_ide_helper_models.php文件 - 添加
"@php artisan ide-helper:generate"和"@php artisan ide-helper:meta"到composer.json文件的scripts.post-update-cmd中 - 执行
php artisan vendor:publish --provider="Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider" --tag=config
- 将
安装多组件Modules
composer require nwidart/laravel-modulesphp artisan vendor:publish --provider="Nwidart\Modules\LaravelModulesServiceProvider"- 自动运行Modules下的组件类,在composer.json文件的
extra.merge-plugin.include下添加"Modules/*/composer.json" - 执行
composer dump-autoload
安装语言包 laravel-lang/lang
composer require --dev laravel-lang/commonphp artisan lang:add zh_CNphp artisan lang:update添加
"@php artisan lang:update"到composer.json文件的scripts.post-update-cmd中
调试工具TeleScope
composer require laravel/telescope --devphp artisan telescope:installphp artisan migratepublic function register(): void { if ($this->app->environment('local')) { $this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class); $this->app->register(TelescopeServiceProvider::class); } }修改
composer.json文件,不被自动发现:"extra": { "laravel": { "dont-discover": [ "laravel/telescope" ] } },在``config/telescopde.php`文件中开启监控选项
'enabled' => env('TELESCOPE_ENABLED', true),版本升级后需要之行
php artisan telescope:publish
选装组件
- JetStream
composer require laravel/jetstream- livewire
php artisan jetstream:install livewire--teams- 按照视图文件,
php artisan vendor:publish --tag=jetstream-views
- inertia
php artisan jetstream:install inertia--ssr
- livewire
npm installnpm run buildphp artisan migrate
- LaravelUI
composer require laravel/uiphp artisan ui bootstrap--authphp artisan ui vue--authphp artisan ui react--authphp artisan ui nestjs
- JetStream
Nginx服务器伪静态配置
location / { try_files $uri $uri/ /index.php?$query_string; }安装TailwindCSS tailwindcss
三、项目结构
ABCD
