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

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

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

2 配置 優化相關參數laravel

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

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

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

'fetch' => PDO::FETCH_ASSOC,

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

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

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

'cookie' => 'pro_site',

3  安裝 擴展包session

  Laravel 5 Repositories  app

 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,  
 
 最後根據官方的說明文檔使用該擴展包

安裝 擴展包composer

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 配置ide

    編輯 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"
相關文章
相關標籤/搜索