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"
posted @ 2017-10-30 15:57  平平淡淡是幸福  Views(4672)  Comments(0Edit  收藏  举报