laravel composer 安裝指定版本以及基本的配置


1 安裝指定的 laravel版本 以下的案例是安裝5.5版本

composer create-project laravel/laravel=5.5.* --prefer-dist

2 配置 優化相關參數

   打開 config/app.php文件 優化以下配置參數   

'timezone' => 'Asia/Shanghai',
'log' => env('APP_LOG', 'daily'),
'log_level' => env('APP_LOG_LEVEL', 'debug'),

   打開 config/database.php  優化以下配置參數

'fetch' => PDO::FETCH_ASSOC,

   打開 config/cache.php 優化以下配置參數

'prefix' => env('CACHE_PREFIX', 'wap_site'),

   打開 config/session.php  優化以下配置參數

'cookie' => 'pro_site',

3  安裝 擴展包

  Laravel 5 Repositories  

 composer require prettus/l5-repository 
 
 編輯 config/app.php
   
 在 providers 數組里面寫入 以下配置
  
  Prettus\Repository\Providers\RepositoryServiceProvider::class,
 
 
 在cmd 下面執行
   
  php artisan vendor:publish  
 
 在 config文件夾下面生成   repository.php
 
   
 編輯   config/repository.php
 
  更改如下
 
  'generator'  => [
      'basePath'      => app_path(),
      'rootNamespace' => 'App\\',
      'paths'         => [
          'models'       => 'Entities',
          'repositories' => 'Repositories\Eloquent',
          'interfaces'   => 'Repositories\Interfaces',
          'transformers' => 'Transformers',
          'presenters'   => 'Presenters',
          'validators'   => 'Validators',
          'controllers'  => 'Http/Controllers',
          'provider'     => 'RepositoryServiceProvider',
          'criteria'     => 'Criteria',
          'stubsOverridePath' => app_path()
      ]
  ]
 
 在 cmd 下面執行
  
  php artisan make:provider    RepositoryServiceProvider 
  然后會自動生成相對應的服務層文件
 
 編輯 config/app.php  在 providers 數組里面寫入
App\Providers\RepositoryServiceProvider::class,  
 
 最后根據官方的說明文檔使用該擴展包

安裝 擴展包

redis 擴展
composer require predis/predis 1.0.*    
laravel-ide-helper 擴展包
composer require barryvdh/laravel-ide-helper  
寫入 config
/app.php文件 Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class,
laravel-debugbar 擴展包
composer require barryvdh/laravel-debugbar 
memcache 擴展
composer require swiggles/memcache
在config / app.php中添加memcache服務提供者:
Swiggles\Memcache\MemcacheServiceProvider::class,
您現在可以更新您的config / cache.php配置文件以使用memcache
'default' => 'memcache',
您現在可以更新config / session.php配置文件以使用memcache
'driver' => 'memcache',

 

 

4 優化 laravel 配置

    編輯 composer.json  

    在 post-update-cmd 數組里面寫入優化的優化參數

"php artisan cache:clear",
"php artisan route:cache",
"php artisan optimize",
"php artisan ide-helper:generate",
"php artisan ide-helper:meta",
"composer dumpautoload",
"php artisan clear-compiled"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM