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

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

       

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

  2 配置 優化相關參數laravel

         

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

      

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

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

       

     'fetch' => PDO::FETCH_ASSOC,

  

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

      

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

  

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

    'cookie' => 'pro_site',

 

3  安裝 擴展包數組

   Laravel 5 Repositories  cookie

    https://github.com/andersao/l5-repositorysession

     

    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擴展包app

    

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

 

 

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