lumen

Lumen 5.3 Authentication

狂风中的少年 提交于 2019-12-11 07:26:43
问题 I have installed Lumen and trying to implement authentication. I am using Laravel Framework version Lumen (5.3.3) (Laravel Components 5.3.*). In app.php I have uncommented the following. $app->withFacades(); $app->routeMiddleware([ 'auth' => App\Http\Middleware\Authenticate::class, ]); $app->register(App\Providers\AuthServiceProvider::class); In \app\Providers\AuthServiceProvider.php public function boot() { $this->app['auth']->viaRequest('api', function ($request) { if ($request->input('api

How to use Authentication for user login in Lumen? Why do I see “Unauthorized” upon launch?

拟墨画扇 提交于 2019-12-11 04:45:50
问题 I have a login page (username/password inputs) that doesn't load/show. Instead, when launching the app, all that shows is "Unauthorized". This is from a command in Authenticate.php that I have included further below. My routes.php : $app->get('/', 'PageController@index'); $app->group(['middleware' => 'middleware.auth'], function ($app) { $app->post('/', ['uses' => 'AuthenticationController@login']); }); My PageController.php : namespace App\Http\Controllers; use App\User; class PageController

Get current route name?

删除回忆录丶 提交于 2019-12-11 03:29:16
问题 In laravel I can use the following to get the current name of the route in my blade template: {{ Route::currentRouteName() }} How can I do the same in Lumen? 回答1: example: <?php $method = Request::getMethod(); $pathInfo = Request::getPathInfo(); $currentRoute = $app->getRoutes()[$method.$pathInfo]; echo $currentRoute['action']['as']; ?> 回答2: I fixed this with: list($found, $routeInfo, $params) = app('request')->route() ?: [false, [], []]; $routeName = isset($routeInfo['as']) ? $routeInfo['as'

Creating new Lumen app on nginx throwing 404 when hiting IP Adress through browser

点点圈 提交于 2019-12-11 01:09:03
问题 I am trying to create a plain Lumen application on ngnix server on Digital Ocean. Following the official documentation for Laravel, I followed everything as it is said until the Laravel Installation bit. Just instead of this composer create-project laravel/laravel /var/www/lumen/ 4.1 I used composer create-project --prefer-dist laravel/lumen blog` instead. The Lumen document seems on the directory now when I use ls . However when I hit the IP address, or IPAdress/index.php, it shows 404 Not

Axios POST request not working

和自甴很熟 提交于 2019-12-10 20:36:06
问题 I know there are lots of question out there with the same issue, but none of the solutions have worked for me yet. I have a ReactJS application consuming an API built in Lumen. The API is also consumed by React Native and JQuery AJAX and works fine on both. When I try to send a POST request with axios from ReactJS, I get a 405 Method Not Allowed error on the OPTIONS Request. The axios request is: const body = { username, password }; axios.post(`{$uri}/payment/api/login`, {body}) .then(res =>

Lumen: Class Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse does not exist

核能气质少年 提交于 2019-12-10 20:24:14
问题 I'm new to Lumen and i am trying to setup authentification using OAuth2 with this tutorial when i try to access any route i got this error: ReflectionException in Container.php line 738: Class Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse does not exist in Container.php line 738 at ReflectionClass->__construct('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse') in Container.php line 738 at Container->build('Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse', array()) in

Target [Laravel\Socialite\Contracts\Factory] is not instantiable

↘锁芯ラ 提交于 2019-12-10 14:19:30
问题 I am using laravel lumen 5.2. Target [Laravel\Socialite\Contracts\Factory] is not instantiable. I came across this error when trying to get Laravel to login with Twitter using the Socialite package. Work already done: A) In config\app.php 1. Laravel\Socialite\SocialiteServiceProvider::class 2. 'Socialite' => Laravel\Socialite\Facades\Socialite::class I followed this : http://goodheads.io/2015/08/24/using-twitter-authentication-for-login-in-laravel-5/ 回答1: What helped me is writing use

response for preflight is invalid (redirect) error

末鹿安然 提交于 2019-12-10 10:49:53
问题 I am new to Laravel and Lumen framework. I am doing my first project using Lumen. I am trying to create an API calling from angular Here is my angular code : app.controller('ListCtrl', ['$scope', '$http', '$location', '$window', function($scope, $http, $location, $window) { $scope.data = {}; $scope.getdata = function() { $scope.datas = []; $headers = { 'Access-Control-Allow-Origin' : '*', 'Access-Control-Allow-Methods' : 'POST, GET, OPTIONS, PUT', 'Content-Type': 'application/json', 'Accept':

Saving many-to-many relationship, sync/attach doesn't exist?

亡梦爱人 提交于 2019-12-10 02:27:47
问题 I have two following 2 models in many-to-many relationship : use Illuminate\Database\Eloquent\Model; class Permission extends Model { /** * The database table used by the model. * * @var string */ protected $table = 'permissions'; /* |-------------------------------------------------------------------------- | Relationship Methods |-------------------------------------------------------------------------- */ /** * many-to-many relationship method * * @return QueryBuilder */ public function

How to use preferredLocale in lumen?

梦想与她 提交于 2019-12-09 19:41:43
问题 With the release of Laravel 5.7 the Illuminate\Notifications\Notification class started offering a locale method to set the desired language. The application will change into this locale when the notification is being formatted and then revert back to the previous locale when formatting is complete. Here is an example of this feature: $user->notify((new InvoicePaid($invoice))->locale('ar')); I just need to use this feature in lumen (latest version) but when I implement that Like documentation