lumen

How to dispatch a Job to a specific queue in Lumen 5.5

痞子三分冷 提交于 2019-12-05 07:02:23
In standard a job I use this method to dispatch a Job: dispatch(new PurchaseJob($trxId, $method, $params)); Next I want to dispatch another Job to send email, but I want to split it to another separate queue. From what I read on Laravel 5.5 docs I could do this: SendEmailJob::dispatch($userEmail)->onQueue('send_email'); But it does not seems to work on Lumen 5.5. What could I do to make this work or is there any other method that are not stated in the docs? I just managed to find a way to dispatch the queue with the specified name in Lumen 5.5. public function toMail($notifiable) { $job = (new

Making use of the base path in Laravel 5 (Lumen)

老子叫甜甜 提交于 2019-12-05 06:58:05
I am using laravel in a project. On my local machine the server I have to access is just laraveltest.dev . When I open this URL the project works fine and without problems. However, when I upload this on a testing server, where the stuff is located in a sub-foder, like this: laraveltest.de/test2/ . The public folder is at laraveltest.de/test2/public/ , but when calling laraveltest.de/test2/public the application always returns an 404 error. I thought this might be because of the base path, so I did the following in the bootstrap/app.php $app = new Laravel\Lumen\Application( realpath(__DIR__.'/

How to use Request->all() with Eloquent models

不打扰是莪最后的温柔 提交于 2019-12-05 05:14:02
I have a lumen application where I need to store incoming JSON Request. If I write a code like this: public function store(Request $request) { if ($request->isJson()) { $data = $request->all(); $transaction = new Transaction(); if (array_key_exists('amount', $data)) $transaction->amount = $data['amount']; if (array_key_exists('typology', $data)) $transaction->typology = $data['typology']; $result = $transaction->isValid(); if($result === TRUE ) { $transaction->save(); return $this->response->created(); } return $this->response->errorBadRequest($result); } return $this->response-

Method Illuminate\\Auth\\RequestGuard::attempt does not exist

丶灬走出姿态 提交于 2019-12-05 00:02:16
I am new to both laravel and lumen. I was creating a login api with oauth2.0 in lumen 5.6, i have installed passport and generated token. Below is my login controller function and it is working fine. It returns token. namespace App\Http\Controllers; use Illuminate\Http\Request; use App\Http\Controllers\Controller; use Illuminate\Support\Facades\Route; //use Illuminate\Support\Facades\DB; use App\User; use Auth; public function login(Request $request) { global $app; $proxy = Request::create( '/oauth/token', 'post', [ 'grant_type' => env('API_GRAND_TYPE'), 'client_id' => env('API_CLIENT_ID'),

PHP Lumen Call to a member function connection() on null

大憨熊 提交于 2019-12-04 22:32:45
Call to a member function connection() on null is the error I'm receiving when trying to use an Eloquent Model in Lumen. Controller func: /** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index(Request $request) { $employees = Employee::orderBy('first_name', 'asc')->get(); dd($employees); $response['precontent'] = view('admin::employee.search')->render(); $response['content'] = view('admin::employee.index') ->with(['employees' => $employees]) ->render(); $response['title'] = 'Employees'; return $response; } Model: <?php namespace App; use

laravel/lumen-framework:“5.7.*” and flipbox/lumen-generator:“^5.6” Class Not Found

故事扮演 提交于 2019-12-04 21:39:40
I think this is related to composer autoload not detecting packages outside laravel/lumen-framework/src Is my above assumption to the below problem correct? Shall I include psr-4 key inside "autoload-dev" nested object? I really appreciate your help. Thanks. Below is Error Exception, composer.json snippet and Stack Trace Logs Below composer.json { ... "autoload": { "classmap": [ "database/seeds", "database/factories" ], "psr-4": { "App\\": "app/" } }, "autoload-dev": { "classmap": [ "tests/" ] }, ... } Below is the stack trace log found under storage/lumen.log [2018-10-09 07:51:53] local.ERROR

Laravel - Collection with relations take a lot of time

半世苍凉 提交于 2019-12-04 20:58:41
We are developing an API with LUMEN. Today we had a confused problem with getting the collection of our "TimeLog"-model. We just wanted to get all time logs with additional informationen from the board model and task model. In one row of time log we had a board_id and a task_id. It is a 1:1 relation on both. This was our first code for getting the whole data. This took a lot of time and sometimes we got a timeout: BillingController.php public function byYear() { $timeLog = TimeLog::get(); $resp = array(); foreach($timeLog->toArray() as $key => $value) { if(($timeLog[$key]->board_id && $timeLog

Does task scheduling in Lumen work just like in Laravel?

廉价感情. 提交于 2019-12-04 17:32:09
问题 You can see task scheduling explained in the latest docs for Laravel, but Lumen's docs do not mention this. However, it looks like Lumen's Console Kernel file has a schedule method just like Laravel. Does scheduling work the same in both, or what are the caveats with scheduling in Lumen? 回答1: Yes, yes it does! :) It works exactly the same. crontab -e And then add * * * * * php /var/www/domain.com/public_html/artisan schedule:run 1>> /dev/null 2>&1 Come to think of it, the php artisan schedule

Laravel/Lumen file response

与世无争的帅哥 提交于 2019-12-04 14:28:59
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. In Lumen you can use Symfony's BinaryFileResponse . use Symfony\Component\HttpFoundation\BinaryFileResponse $type = 'image/png'; $headers = ['Content-Type' => $type]; $path = '/path/to/you/your/file

自主开发lumen的composer包

怎甘沉沦 提交于 2019-12-04 08:37:46
以我开发的zero/lumen-elasticsearch包为例 ###注意本插件使用的是lumen框架 ####1.安装依赖 composer require zzq/lumen-elasticsearch ####2.创建elasticsearch.php配置文件,文件内容如下: <?php return [ /** * You can specify one of several different connections when building an * Elasticsearch client. * * Here you may specify which of the connections below you wish to use * as your default connection when building an client. Of course you may * use create several clients at once, each with different configurations. */ 'defaultConnection' => 'default', /** * These are the connection parameters used when building a client. */ 'connections'