artisan

Using verbose in Laravel artisan commands

爷,独闯天下 提交于 2019-12-04 23:03:00
Is there a way to detect what verbosity level the user has specified when creating a custom artisan command? I don't see anything about it in the docs. There's the getVerbosity() function in Symfony\Component\Console\Output\OutputInterface and you can use $this->getOutput() to retrieve the output object. $verbosityLevel = $this->getOutput()->getVerbosity(); You then can compare the level to the constants defined inside OutputInterface . For example: if($verbosityLevel >= OutputInterface::VERBOSITY_VERBOSE){ // show verbose messages } You can use different verbosities as per the documentation:

Laravel 5 - how to run a Controller method from an Artisan Command?

倖福魔咒の 提交于 2019-12-04 22:48:50
问题 I need some code from my Controller to run every ten minutes. Easy enough with Scheduler and Commands . But. I've created a Command , registered it with Laravel Scheduler (in Kernel.php ) and now I am unable to instantiate the Controller . I know it's a wrong way to approach this problem, but I just needed a quick test. Is there a way, mind you a hacky way, to accomplish this? Thank you. Update #1: The Command : <?php namespace App\Console\Commands; use Illuminate\Console\Command; use App

Laravel: Running queue:listen continuously on Windows Azure Web App

大兔子大兔子 提交于 2019-12-04 21:52:26
问题 I feel a little bit silly for asking this question but I can't seem to find an answer on the internet for this problem. After searching for several hours I figured out that on a linux server you use Supervisor to run "php artisan queue:listen" (either with or without daemon) continuously on your website to handle jobs pushed to the queue. This is all well and good, but what if I want to do this on a Windows Azure web app? After searching around the solutions I found were: Make a chron job to

Install LARAVEL 5 Locally Same as Share Hosting Directory (Deploy L5 Share Hosting Solution)

ぃ、小莉子 提交于 2019-12-04 20:38:17
I am trying to find the way to organise my Laravel Application same as share hosting directory. Example inside " server " folder 1.Install fresh laravel application composer create-project laravel/laravel main-app --prefer-dist 2.Move "Public" directory up and next to main-app folder.Rename to public_html 3.Inside public_html folder also create new "app" folder to keep all the files like inside index.php Summary server │ └───main-app │ │ app │ │ bootstrap │ │ ...... │ └───public_html │ app │ │─── index.php │ This is what I need to do.But I couldn't make this work! Each time I try to run

“SQLSTATE[HY000] [2002] No such file or directory” error when migrating table in Laravel

社会主义新天地 提交于 2019-12-04 18:13:35
I am getting the following error when I try to migrate a table in Laravel 5 using the "php artisan migrate" command: 'SQLSTATE[HY000] [2002] No such file or directory' in . . . /vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47 My .env file includes the default settings as follows: DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret My database.php file lists mysql as the default database connection, homestead is listed as the database in my homestead.yaml file, and homestead is one of the tables listed when I access mysql and use the

Laravel php artisan db:seed leads to “use” statement error

时光总嘲笑我的痴心妄想 提交于 2019-12-04 15:38:59
问题 When I try to run php artisan db:seed I get the following error: The use statement with non-compound name 'DB' has no effect I have written my own seeder file which I have included below, based on a snippet from the doc. As you can see I am using the use DB shortcut - is this what the problem is? <?php use Illuminate\Database\Seeder; use Illuminate\Database\Eloquent\Model; use DB; class ClassesTableSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run()

Laravel 5: run migrations on server environment, not local

懵懂的女人 提交于 2019-12-04 12:37:09
I have a simple set of database migrations created within my Laravel 5 application, and they run nicely on my local development environment. Now its time to run to run the migration on my new production server environment. I have configured the DB connection and deployed the app, and the app sees the database, but there are no tables - so migrations need to be run. The following command, I believe, should run the migrations using the "production" environment, which is set up with the remote DB connection details: php artisan --env=production migrate The migration works, but it runs on the

Laravel migration (errno: 150 “Foreign key constraint is incorrectly formed”)

落爺英雄遲暮 提交于 2019-12-04 08:27:51
问题 I have an orders table and a have a sell_shipping_labels which references orders.id as a foreign. However when I run the Laravel migration I get the dreaded error code: [Illuminate\Database\QueryException] SQLSTATE[HY000]: General error: 1005 Can't create table cheapbooks_test . #sql-b5b_b2a (errno: 150 "Foreign key constraint is incorrectly formed") (SQL: alter table sell_shipping_labels add constraint sell_shipping_labels_order_id_foreign foreign key ( order_id ) references orders ( id ))

Is there any Laravel way to execute a .SQL file to load data

扶醉桌前 提交于 2019-12-04 05:35:24
I have historical data that I want to load in new DB. I could do it by running MySQL command but I am interested to know whether there are artisan commands to do it? There isn't a way to import a DB dump out-of-the-box using artisan . However, you could create a custom artisan command: php artisan make:console DbImportCommand and then have it issue a command like: DB::unprepared(file_get_contents('full/path/to/dump.sql')); However, it may be advantageous to create a command that runs a seeder (or set of seeders). php artisan make:console importHistoricalData and then have that run specific

Xdebug laravel artisan commands

末鹿安然 提交于 2019-12-04 05:06:23
I regularly use xdebug to debug applications, I've built a laravel application that takes an upload of a csv inserts the data to the database and the ids to a job queue. I've written an artisan command to be run via cron to then do something with this data. Xdebug works for accessing the site via the browser, but its not breaking on breakpoints when ran from cli. I run php5-fpm. My files /etc/php5/fpm/php.ini and /etc/php5/cli/php/ini both contain the following settings: zend_extension=/usr/lib/php5/20121212/xdebug.so xdebug.remote_enable = 1 xdebug.idekey = 'dev_docker' xdebug.remote