lumen安裝
- 安裝器安裝
1. composer global require "laravel/lumen-installer"
2. lumen new blog
- composer安裝
composer create-project --prefer-dist laravel/lumen blog
服務提供者
使用緩存cache(redis緩存)
- 安裝依賴包
composer require predis/predis 1.0.*
composer require illuminate/redis
- 配置
bootstrap/app.php 文件中註冊Illuminate\Redis\RedisServiceProvider
$app->register( Illuminate\Redis\RedisServiceProvider::class );
- 加載Eloquent/配置
3.1 只加載配置
$app->configure('database');
3.2同時加載Eloquent
$app->withEloquent();
- 使用門面
$app->withFacades();
- 使用
app('redis')->set('redisKey', 'abc123');
//門面Redis
Redis::set('redisKey', 'abc123');
- 默認使用predis客戶端
vendor/illuminate/redis/RedisServiceProvider.php
return new RedisManager(Arr::pull($config, 'client', 'predis'), $config);
app('cache')->put('cacheKey', '123abc', 2);
//門面Cache
Cache::put('cacheKey', '123abc', 2);
lumen輔助函數位置
vendor/illuminate/support/helpers.php
lumen配置文件位置
vendor/laravel/lumen-framework/config