Jake Jake - 3 months ago 35
PHP Question

make:command not defined in Laravel 5.1.7

I'm trying to use the

make:console
to create a scheduler, however it's returning:

[InvalidArgumentException]
Command "make:console" is not defined.
Did you mean one of these?
make:seeder
make:migration


Fair enough if this was before version 5.0, but I'm currently using 5.1.7. What could cause this issue?

Here's a list of the current available commands:

help Displays help for a command
list Lists commands
migrate Run the database migrations
serve Serve the application on the PHP development server
cache
cache:clear Flush the application cache
cache:table Create a migration for the cache database table
db
db:seed Seed the database with records
make
make:migration Create a new migration file
make:seeder Create a new seeder class
migrate
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
queue
queue:failed List all of the failed queue jobs
queue:failed-table Create a migration for the failed queue jobs database table
queue:flush Flush all of the failed queue jobs
queue:forget Delete a failed queue job
queue:listen Listen to a given queue
queue:restart Restart queue worker daemons after their current job
queue:retry Retry a failed queue job
queue:subscribe Subscribe a URL to an Iron.io push queue
queue:table Create a migration for the queue jobs database table
queue:work Process the next job on a queue
schedule
schedule:run Run the scheduled commands


If I modify
composer.json
to version 5.2.* I receive an even slimmer selection of commands:

help Displays help for a command
list Lists commands
migrate Run the database migrations
cache
cache:clear Flush the application cache
db
db:seed Seed the database with records
make
make:migration Create a new migration file
migrate
migrate:install Create the migration repository
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
migrate:status Show the status of each migration
queue
queue:failed List all of the failed queue jobs
queue:flush Flush all of the failed queue jobs
queue:forget Delete a failed queue job
queue:listen Listen to a given queue
queue:restart Restart queue worker daemons after their current job
queue:retry Retry a failed queue job
queue:work Process the next job on a queue
schedule
schedule:run Run the scheduled commands

Answer

I find a work-around. Even though my Laravel CLI was missing the previously mentioned commands, I still had the scheduling and command file structure to manipulate.

Manually create example_scheduled_command.php in the Commands directory and register it in Kernal.php. Then you can utilise that for Laravel Scheduling.