lumen

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

江枫思渺然 提交于 2020-01-03 12:33:12
问题 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

How to change the Public directory path in Lumen?

对着背影说爱祢 提交于 2020-01-02 11:29:52
问题 By default Lumen "same as Laravel" has myApp/public directory to put all the public files (assets). I want to change that directory path from myApp/public to myApp/src/custom/public . How can I do achieve this? 回答1: Got the same problem, and solved it. Look here, maybe it will help you. I have done this solution for my Lumen application, which works for me. UPDATE Ok, let's go proceeding some changes to make the system to work with your tree. Add a .htaccess file in the root of your

lumen 登陆 注册 demo

时间秒杀一切 提交于 2020-01-02 08:37:09
本文将用Lumen来实现一个完整的用户注册、登录及获取用户信息的API。 Lumen环境搭建和初始化详细步骤请参考上篇文章 《Lumen安装配置使用入门》 一文。 一、准备工作 1、Lumen环境搭建 可参考上篇文章 《Lumen安装配置使用入门》 一文。 2、数据库信息 数据库地址:localhost 数据库名称:lumenauth 数据库用户:root 数据库密码:****** 二、初始化Lumen lumen new LumenAuth 三、配置 1、数据库配置 在命令行进入项目所在文件夹,执行命令: copy .env.example .env 用文本编辑器打开.env文件,根据之前准备的数据库信息作相应修改。 --------------------------------------- LumenAuth\.env --------------------------------------- APP_ENV=local APP_DEBUG=true APP_KEY= DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=lumenauth DB_USERNAME=root DB_PASSWORD= CACHE_DRIVER=memcached QUEUE_DRIVER=sync ---------

Lumen error when using artisan migrate

我怕爱的太早我们不能终老 提交于 2020-01-02 05:50:28
问题 I'm new to Lumen and when I try to use: php artisan migrate I get the following error. [PDOException] SQLSTATE[HY000] [2002] No such file or directory If I change 'localhost' to '127.0.0.1' I get this error: [PDOException] SQLSTATE[HY000] [2002] Connection refused If I use: php artisan migrate --database=Lumen I get: [InvalidArgumentException] Database [Lumen] not configured. Here is my .env file DB_CONNECTION=mysql DB_HOST=localhost DB_PORT=3306 DB_DATABASE=Lumen DB_USERNAME=root DB_PASSWORD

Method addEagerConstraints does not exist

不问归期 提交于 2020-01-02 04:47:12
问题 I have two models, User and Event. I made a pivot table, invitations between User and Event with a status column. In my Event model definition, I wrote this : public function invited() { return $this->belongsToMany(User::class, 'invitations', 'event_id', 'user_id') ->withTimestamps() ->withPivot('status') ->orderByDesc('invitations.updated_at'); } public function participants() { $event = $this->with([ 'invited' => function ($query) { $query->where('invitations.status', InvitationStatus:

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

北战南征 提交于 2020-01-02 03:28:29
问题 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-

Lumen 5.6 Migrate Error Specified key was too long max key length is 767 bytes

会有一股神秘感。 提交于 2020-01-01 10:15:09
问题 I use Lumen 5.6 and mysql. when i type "php artisan migrate" following error occur: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was t oo long; max key length is 767 bytes (SQL: alter table `users` add unique ` users_email_unique`(`email`)) I put following code into "boot" method in the AppServiceProvider Schema::defaultStringLength(191); but I didn't achieve to any success. 回答1: you just need one more step go to app.php on bootstrap folder and uncomomment or modif

Where to register Facades & Service Providers in Lumen

给你一囗甜甜゛ 提交于 2019-12-31 08:44:16
问题 I Am looking for where to add the facade below in Lumen. 'JWTAuth' => 'Tymon\JWTAuth\Facades\JWTAuth' EDITED Also where to register service provider in bootstrap\app.php $app->register('Tymon\JWTAuth\Providers\JWTAuthServiceProvider'); Please assist. 回答1: In your bootstrap/app.php , make sure you've un-commented: $app->withFacades(); Then, register you class alias and check if it already exists (else your tests will break): if (!class_exists('JWTAuth')) { class_alias('Tymon\JWTAuth\Facades

Lumen make:command

ⅰ亾dé卋堺 提交于 2019-12-29 18:36:29
问题 I'm trying to execute code within my Lumen install via the command line. In full Laravel , I've read that you can use commands to achieve this via "make:command", but Lumen does not seem to support this command. Is there anyway to enable this command? Failing that, what's the best way of running code from the CLI in Lumen? Thanks 回答1: You can use the artisan CLI in Lumen as the same way as in Laravel but with fewer built-in commands. To see all built-in commands, use the php artisan command

Unable to use Laravel / Socialite with Lumen

纵饮孤独 提交于 2019-12-29 07:18:25
问题 I try to use the package Laravel\Socialite in my system in Lumen (5.1) I added this in the config\services.php file : <?php //Socialite 'facebook' => [ 'client_id' => '##################', 'client_secret' => '##################', 'redirect' => 'http://local.dev/admin/facebook/callback', ], In bootstrap\app.php file : class_alias(Laravel\Socialite\Facades\Socialite::class, 'Socialite'); $app->register(Laravel\Socialite\SocialiteServiceProvider::class); Then I created a controller for the