lumen

Laravel 5 / Lumen Request Header?

别等时光非礼了梦想. 提交于 2019-12-03 09:52:12
So I am not really sure how to go about this I have tried a few things and I will list one below however what I am trying to do is store information sent in a http request in a PHP variable. Here is a view from Chrome Postman of me sending the request I want ot send. Note "pubapi" is a "header". I have been messing around with Lumen requests as you can see documented here ( http://lumen.laravel.com/docs/requests ) and have tried using the following below to possibly display them but its not working obviously. echo Request::all(); I am putting this in my controller and I have ... use Illuminate

How to use multiple database in Lumen

旧巷老猫 提交于 2019-12-03 08:47:40
We've using Lumen for building API's , Now we need to access multiple databases. Currently using .env for database config but unable to found the way to multiple databases in .env where we need to read 2nd connection ... First, you'll need to configure your connections. If you don't already have one you'll need to create a config directory in your project and add the file config/database.php . It might look like this: <?php return [ 'default' => 'accounts', 'connections' => [ 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST'), 'port' => env('DB_PORT'), 'database' => env('DB_DATABASE'),

Creating custom error page in Lumen

↘锁芯ラ 提交于 2019-12-03 03:20:41
How do I create custom view for errors on Lumen? I tried to create resources/views/errors/404.blade.php , like what we can do in Laravel 5, but it doesn't work. Errors are handled within App\Exceptions\Handler . To display a 404 page change the render() method to this: public function render($request, Exception $e) { if($e instanceof NotFoundHttpException){ return response(view('errors.404'), 404); } return parent::render($request, $e); } And add this in the top of the Handler.php file: use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; Edit: As @YiJiang points out, the response

NotFoundHttpException with Lumen

匿名 (未验证) 提交于 2019-12-03 02:59:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: 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 method is faster than accessing class alias via array

Laravel Lumen Memcached not found

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Ok, I just started with Lumen and I'm trying to use the Auth, but a call to either Auth::check or any other function of Auth.. leads to the below Error Fatal error: Class 'Memcached' not found in vendor\illuminate\cache\MemcachedConnector.php on line 52 . I don't want to use Memcached never used it before. I disabled it in the .env file and set the CACHE_DRIVER and SESSION_DRIVER to array, but still shows the same error. I decided not to use Auth again and to manually handle my authetication with sessions/tokens, but enabling the MiddleWare

Lumen Daily Logs

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to add to my Lumen project a daily Log. I try this in the app.php (Folder Bootstrap/) $logFile = 'laravel.log'; Log::useDailyFiles(storage_path().'/logs/'.$logFile); But this set me that error Call to undefined method Monolog\logger::useDailyFiles() Any help I appreciate...Thanks 回答1: If you look at the framework source code here you can see that it will not do daily logs, but rather write to a single log file lumen.log . There is a public method available configureMonologUsing seen here and referenced here that you can use to

Lumen and MongoDB?

匿名 (未验证) 提交于 2019-12-03 02:05:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Is it somehow possible to include the mongodb connection settings into a lumen framework. As from what I saw the config/database.php is loaded internally in the lumen package. Is there a way to extend it somehow to include the mongodb connection settings? 回答1: We're actually using Lumen, Laravel, Mongo, and MySQL in one giant project so I can help you through this one. Assuming you want to use MongoDB with eloquent instead of with the raw MongoClient. You can find the library I'm using from jenssegers here . Install MongoDB Extension Firstly

Laravel/Lumen file response

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to stream file content (such as images and other mime types) from a Lumen resource server to a Laravel client server. I know in Laravel I can use: $headers = ['Content-Type' => 'image/png']; $path = storage_path('/mnt/somestorage/example.png') return response()->file($path, $headers); However, the file method is absent in Laravel\Lumen\Http\ResponseFactory . Any suggestions are very welcome. 回答1: In Lumen you can use Symfony's BinaryFileResponse . use Symfony\Component\HttpFoundation\BinaryFileResponse $type = 'image/png'; $headers =

How to integrate Swagger in Lumen/Laravel for REST API?

霸气de小男生 提交于 2019-12-03 01:24:46
I have built some REST API in Lumen micro framework and it's working fine. Now I want to integrate Swagger into it so the API will be well documented on future use. Has anyone done this? Steps to follow for Laravel Lumen 5.7 with swagger using OpenApi 3.0 specs (this governs the way you write annotations so that swagger documentation is generated) I reached this adjusting on @black-mamba answer in order to make it work. 1. Install swagger-lume dependency (which also installs swagger) composer require "darkaonline/swagger-lume:5.6.*" 2. Edit bootstrap/app.php file make sure $app->withFacades();

lumen: App\\Http\\Controllers\\Controller class not found with fresh install

匿名 (未验证) 提交于 2019-12-03 00:52:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm working with a fresh install of Lumen (building a web API), most things work but when i'm trying to use the router to point to a class i get this error: Fatal error: Class 'App\Http\Controllers\Controller' not found in /Applications/MAMP/htdocs/moments/lumen/app/Http/Controllers/MomentController.php on line 5 This is my router in app/Http/routes.php $app->get('/', 'MomentController@index'); And this is my class in app/Http/Controllers/MomentController.php <?php namespace App\Http\Controllers; use App\Http\Controllers\Controller; class