lumen

Lumen 5.5 JSON API File Upload test breaks with UploadedFile

做~自己de王妃 提交于 2019-12-25 09:49:07
问题 I am building a file upload JSON API with Lumen and trying to write phpunit API tests. The problem I am having though is that as soon as I try to simulate a file upload with a real image constructed like ["file" => new UploadedFile(TestUtils::tempPath('test.jpg'), 'test.jpg', "image\jpeg", 100, null, true)] and sending it via $this->json('POST', '/chunk', $data); , I can't do anything with the uploaded file because it is an array and I get the error Call to a member function move() on array

How to change LOCALE language on Lumen

故事扮演 提交于 2019-12-25 03:42:37
问题 I saw this question, but it don't answers me. I have set APP_LOCALE=fr in the .env file, but I still get date in english format : string 'Thursday, 09h00' (length=15) And I would like to get : string 'Jeudi, 09h00' (length=12) How to change from english to french on Lumen Framework ? (Added PHP tag to be more seen) 回答1: In lumen you cannot set the locale in your config. You can however change the locale in code by using app('translator')->setLocale($locale); . In my own projects I set the

Setting response headers with middleware in Lumen

北战南征 提交于 2019-12-25 03:33:26
问题 I'm trying to set a header ( X-Powered-By ) using an AfterMiddleware in the Lumen micro-framework. Unfortunately, the header isn't being set. It is assumed that the middleware (shown below) isn't even being handled. AfterMiddleware.php <?php namespace App\Http\Middleware; use Closure; class AfterMiddleware { public function handle($request, Closure $next) { $response = $next($request); $response->header('X-Powered-By', env('APP_NAME') . '/' . env('APP_VER')); return $response; } } bootstrap

How to pass headers from AWS API Gateway

我怕爱的太早我们不能终老 提交于 2019-12-24 19:15:26
问题 I'm passing the addition key-value pairs from lambda function, same as mention in aws labs. Then in API Gateway I have setup the body mapping templates in integration request. (Check this). But when request goes to the endpoint (PHP) then I'm unable to get any data. It is empty array print_r($_REQUEST); I checked cloudWatch this is what it is showing. Endpoint request body after transformations: { "userData" : "{"city":"USA","Name":"Sanket","id":3}" } Additional info - When I print print_r($

Obtaining result from async API

为君一笑 提交于 2019-12-24 14:10:28
问题 I am building API for processing with Lumen, the processing job is taking around 1-3 seconds per request. So far i did it with job queue and beanstalkd and it is asynchronous, meaning i return job_id that i can check later for the result. I am also writing PHP client to utilize the API and for that i am wondering if i should include 'wait' parameter server side or client side? If wait is implemented serverside i will need to sleep and check the database for results once the job is dispatched

Route with dot (IP address) not found, returns 404

删除回忆录丶 提交于 2019-12-24 11:56:01
问题 I use Lumen 5.4 . This is how my route is setup: $app->get('/ip/{ip}', GeoIpController::class . '@show'); The {ip} route parameter should be an IP address, with dots in it. However, it seems there is a problem when a route has dots in it. It returns a 404 not found error. I am aware I could pass the IP address in as a simple GET request parameter, but want the IP to be part of the URL and to be handled like a route parameter. For testing purposes, I use php -S localhost:8080 -t public to

Missing argument 1 for Illuminate\Auth\AuthManager::createDriver() lumen and JWT

妖精的绣舞 提交于 2019-12-24 11:54:12
问题 I am trying to implement JWT token in my API using Lumen + JWT . I am using this JWT Library, I have set up it, but when I want to validate passed using JWTAuth::attempt($credentials) I get next error ErrorException in AuthManager.php line 16: Missing argument 1 for Illuminate\Auth\AuthManager::createDriver(), called in /home/admin/web/mkopilka.ru/public_html/api/referral/vendor/illuminate/support/Manager.php on line 87 and defined I know where is the problem, but cannot figure out how to

Job chaining in Lumen 5.5: withChain() not working how can I make it work?

浪子不回头ぞ 提交于 2019-12-24 11:51:42
问题 For dispatching a single job I usually do one of these: Queue::push(new ExampleJob); or dispatch(new ExampleJob); https://lumen.laravel.com/docs/5.5/queues According to the Laravel Docs a certain Job chain, where one Job depends upon the previous is done like this: ExampleJob::withChain([ new OptimizePodcast, new ReleasePodcast ])->dispatch(); https://laravel.com/docs/5.5/queues#job-chaining However this does not workin in Lumen (similar problem here: How to dispatch a Job to a specific queue

Lumen: print custom config return NULL

放肆的年华 提交于 2019-12-24 02:06:30
问题 I placed the configuration directory in the application root: /config/app.php Contents of /config/app.php: <?php return [ 'test' => 'this config should work', ]; In the /bootstrap/app.php: $app->configure('app'); To test: dd(config('app.test')); Result is NULL :(. How can I fix it? I see that there is the same issue on github (https://github.com/laravel/lumen-framework/issues/107) but I have already updated my Lumen at the last version. 回答1: I added following lines just before return $app;

Lumen: print custom config return NULL

柔情痞子 提交于 2019-12-24 02:06:05
问题 I placed the configuration directory in the application root: /config/app.php Contents of /config/app.php: <?php return [ 'test' => 'this config should work', ]; In the /bootstrap/app.php: $app->configure('app'); To test: dd(config('app.test')); Result is NULL :(. How can I fix it? I see that there is the same issue on github (https://github.com/laravel/lumen-framework/issues/107) but I have already updated my Lumen at the last version. 回答1: I added following lines just before return $app;