Download the PHP package vinlon/laravel-skeleton without Composer
On this page you can find all versions of the php package vinlon/laravel-skeleton. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-skeleton
Laravel Skeleton 应用开发基础模板
更新日志
v0.2.0 升级larvel版本到8.x,默认引入调试工具telescope, 查看telescope使用文档 v0.1.9: 自定义 make:model 和 make:enum 命令使用的 stub 模板,适量减少重复性的工作
功能
在 laravel/laravel:7.x 的基础上增加以下功能
- [x] 增加 DB_PREFIX 环境变量
- [x] 引入 sql-logger, 并配置专用的 log channel
- [x] 引入 ide-helper 并调整配置
- [x] 配置 php-cs-fixer 和 composer-git-hooks
- [x] 简化 .env.example(只保留必要的项)
- [x] 增加 scratch.php 文件模板,用于快速启动 laravel 并执行一段代码
- [x] 定义 BaseModel , 继承后自动实现日期序列化和fillable字段定义,并自定义 make:model 模板,默认继承BaseModel
- [x] 集成 bensampo/laravel-enum,并自定义 make:enum 模板,默认继承 LocalizedEnum 接口,重写 toArray 方法
- [x] composer 使用阿里云的镜像源
使用
使用composer create-project 创建项目
执行 php init
, 然后按提示进行操作,对项目进行初始化
日期格式
从 laravel 7 开始,调用 Eloquent Model 的 toArray方法,日期字段的输出格式为 2020-12-10T09:28:59.000000Z
可通过在 Model 中 use SerializeDateTrait;
或 extend BaseModel
将日期输出格式修改为 2020-12-10 09:28:59
IDE-Helper
目前只用到了 ide-helper-models, 使用 @mixin 方式,对 Model 类的影响最小,将变化集中到 _ide_helper_models.php 文件中
可使用如下命令生成 _ide_helper_models.php 文件
或者使用 composer 命令
代码格式化
手动执行
使用 git-hook 在提交代码时自动执行
在 composer.json 文件中,为 pre-commit 和 pre-push 事件定义了 git-hook.
- pre-commit: 在 commit 代码前会调用 fix-staged-php-files 脚本,该脚本会修复所有待提交文件的格式。
- pre-push: 在 push 代码前会检查所有 php 文件,如果有需要格式化的文件则 push 失败, 此时需要手动执行 composer fix-style, 然后 commit 格式化后的代码,再重新 push。
Enum的使用
常用功能
创建Enum类
Eloquent Model 属性转换
自定义 $model->toArray() 的行为
数据验证
定义 description 属性
常用静态方法
生成注解
参考
All versions of laravel-skeleton with dependencies
bensampo/laravel-enum Version ^3.0
fideloper/proxy Version ^4.4
fruitcake/laravel-cors Version ^2.0
guzzlehttp/guzzle Version ^7.0.1
laravel/framework Version ^8.0
laravel/tinker Version ^2.5
vinlon/laravel-sql-logger Version ^0.2