jeremieflahaut/laravel-api-starter-kit 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jeremieflahaut/laravel-api-starter-kit

最新稳定版本:0.0.4

Composer 安装命令:

composer create-project jeremieflahaut/laravel-api-starter-kit

包简介

The skeleton application for the Laravel framework.

README 文档

README

Installation

you may create a new Laravel project via the Composer create-project command:

    composer create-project jeremieflahaut/laravel-api-starter-kit <project name>

if you are on Docker you can use official Composer Image :

    docker run --rm --interactive --tty --volume $PWD:/app --user $(id -u):$(id -g) \ 
        composer create-project jeremieflahaut/laravel-api-starter-kit <project name>

migrations to database (by default it's sqlite see your .env)

    cd <project name> && php artisan migrate

Start Laravel's local development server using the Laravel's Artisan CLI serve command:

    php artisan serve

Features

Github workflow for laravel test

Laravel tests are run in Github runner . The coverage badge will be pushed to a Badges branch. To do this, you must provide read and write access to the workflow.

To do this, go to settings >> Actions >> General >> Workflow permissions in your repository.

Tests Coverage

Enforcing Strict Behavior in Development with shouldBeStrict

    Model::shouldBeStrict(! $this->app->isProduction());
public static function shouldBeStrict(bool $shouldBeStrict = true)
{
    static::preventLazyLoading($shouldBeStrict);
    static::preventSilentlyDiscardingAttributes($shouldBeStrict);
    static::preventAccessingMissingAttributes($shouldBeStrict);
}

In our starter kit, we've adopted the shouldBeStrict method to optimize application performance and enforce better coding practices, especially in a production environment. This method, located in the boot() method of app/Providers/AppServiceProvider.php, is defined as follows:

  1. preventLazyLoading($shouldBeStrict)
  • Functionality: When set to true, this function throws an exception if lazy loading is attempted on Eloquent models. Lazy loading, while useful in development, can lead to numerous unoptimized database queries in production, impacting performance.
  • Benefit: Encourages the use of eager loading strategies, thus reducing database load and enhancing application efficiency.
  1. preventSilentlyDiscardingAttributes($shouldBeStrict)
  • Functionality: This ensures that any attempt to set attributes that do not exist on the model will throw an exception. Normally, Laravel silently discards such assignments, which can mask typos or logic errors.
  • Benefit: Increases code robustness by avoiding silent failures and ensuring data integrity.
  1. preventAccessingMissingAttributes($shouldBeStrict)
  • Functionality: When enabled, trying to access undefined or non-existent attributes on a model will result in an exception. By default, Laravel returns null for undefined attributes, which can lead to subtle bugs.
  • Benefit: Enhances code safety by making attribute access more explicit and preventing unnoticed errors due to undefined attributes.

Force Https for all generated url in Production

We force https on with the url generator in boot() method of app/Providers/AppServiceProvider.php.

    if ($this->app->isProduction()) {
        URL::forceScheme('https');
    }

laravel pint

We added a git pre hook before each commit to run laravel pint on the php files that will be in the commit. For this we execute this command in post-autoload-dump composer script:

    [ -d .git ] && git config core.hooksPath .hooks || true

We invite you to see the .hooks/pre-commit and pint.json files for configuring laravel pint.

Installed packages

Here are the dependencies added after installing laravel 10.x

License

The Laravel framework is open-sourced software licensed under the MIT license.

统计信息

  • 总下载量: 17
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-09-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固