lumen

Enabling session in lumen framework

戏子无情 提交于 2019-11-27 15:03:41
问题 I have two (but let's image more) micro-services (API) which need to be aware of authenticated user. Ideally I would simple like to resume their sessions. All micro-services are using same storage for sessions: redis. All API calls will have Cookie header, so all services will be able to resume sessions based on that cookie. I have successfully implemented this via PHP $_SESSIONs. Now the question: how would you go about implementing this with Laravel/Lumen? 回答1: The accepted answer is

Change Timezone in Lumen or Laravel 5

拥有回忆 提交于 2019-11-27 13:53:02
I am using Lumen framework. How can I change Timezone to Europe/Paris CEST? I added a varaible in my .env file: APP_TIMEZONE=Europe/Paris But this doesnt work. What is the right way to update timezone? You can set your app time zone by configuring app.php file in config folder . To change time zone , modify the value of timezone in app.php file. This is written in this section |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone

NotFoundHttpException with Lumen

混江龙づ霸主 提交于 2019-11-27 02:58:17
I've just installed Lumen on Windows and unfortunately I'm getting the following error: NotFoundHttpException in Application.php line 1093: in Application.php line 1093 at Application->handleDispatcherResponse(array('0')) in Application.php line 1063 at Application->dispatch(null) in Application.php line 1006 at Application->run() in index.php line 28 What may be the problem here? On your index.php file. Change this line $app->run(); Into: $app->run($app->request); Update Using make method is faster than accessing class alias via array access. This one also works: $app->run( $app->make(

Lumen - Create database connection at runtime

我是研究僧i 提交于 2019-11-27 02:29:58
问题 In a Lumen project, I need to create database connections on runtime, but I keep getting a "Database [...] not configured" error, each time I try to use a recently created connection. This is my test code on routes.php: <?php $app->get('/', function () use ($app) { $config = $app->make('config'); $config->set('database.connections.retail_db', [ 'driver' => 'pgsql', 'host' => env('RETAIL_DB_HOST', 'localhost'), 'port' => env('RETAIL_DB_PORT', 5432), 'database' => env('RETAIL_DB_DATABASE',

Differences and Similarities Between Lumen and Laravel

徘徊边缘 提交于 2019-11-26 23:52:33
问题 I read the documentation and it seems Lumen is Laravel with less features. I must be missing something. I am looking for a comparison table of the components and features of both Laravel and Lumen. Does anyone know the differences? 回答1: Update (5.2) With the latest version of Lumen (5.2) the Microframework focuses on Stateless APIs. The documentation states: Lumen 5.2 represents a shift on slimming Lumen to focus solely on serving stateless, JSON APIs. As such, sessions and views are no

Lumen/laravel Event Demo

别等时光非礼了梦想. 提交于 2019-11-26 17:28:04
最近在学习lumen,想用它来编写接口,学习过程中做点记录; 首先,按照 官方 介绍,创建 lumen project: composer create-project --prefer-dist laravel/lumen lumenEventDemo    项目创建完成,下面进入正题; 事件,通常来讲事件就是某种行为,laravel给我们定义了一个简单的模型,事件包含事件本身,订阅、监听器以及事件的发起; 按照上面的概念,我们来所以下定义: 事件本身(事件名称):一边来讲是以某个动作发生为名词,比如:OnClieck,OnCliecked,On UserCreated,OnDbError等, 这里举例为:ExampleEvent; 事件监听器:就是一个简单事件用来,可用来做一些代码处理,这里我们叫:ExampleListener; 好的,基础工作确定好了,那么就开始编程呗; 首先定义好事件,在“App\Events\"下,创建文件"ExampleEvent.php",并编写如下代码: <?php namespace App\Events; class ExampleEvent extends Event { public $data; /** * Create a new event instance. * * @return void */ public function _

Change Timezone in Lumen or Laravel 5

江枫思渺然 提交于 2019-11-26 16:11:31
问题 I am using Lumen framework. How can I change Timezone to Europe/Paris CEST? I added a varaible in my .env file: APP_TIMEZONE=Europe/Paris But this doesnt work. What is the right way to update timezone? 回答1: You can set your app time zone by configuring app.php file in config folder . To change time zone , modify the value of timezone in app.php file. This is written in this section |-------------------------------------------------------------------------- | Application Timezone |------------

NotFoundHttpException with Lumen

半世苍凉 提交于 2019-11-26 10:18:00
问题 I\'ve just installed Lumen on Windows and unfortunately I\'m getting the following error: NotFoundHttpException in Application.php line 1093: in Application.php line 1093 at Application->handleDispatcherResponse(array(\'0\')) in Application.php line 1063 at Application->dispatch(null) in Application.php line 1006 at Application->run() in index.php line 28 What may be the problem here? 回答1: On your index.php file. Change this line $app->run(); Into: $app->run($app->request); Update Using make