The command "event:cache" does not exist in Laravel 7? - php

I'm running unit test using phpunit on laravel 7
After running command vendor/bin/phpunit then tests/bootstrap.php will be executed.
in that file,we can see event:cache inside the array $commands
$commands = ['event:cache']
The result in the terminal shown as follows
The command "event:cache" does not exist
Has the name of the command changed for Laravel 7?

Related

Lumen 5.3: Set php artisan environment

How can I set environment variable of a php artisan command using Lumen 5.3? Laravel 5.0 says:
php artisan migrate --env=local
But in newer version documentations this section is disappeared. I run this my command like:
php artisan myCommand --env=testing
But both in my command class and bootstrap file (simply everywhere) dumping env(APP_ENV) results in local
Any suggestions?
It's as simple as
APP_ENV="production" php artisan myCommand
Or in multiple environment as
APP_ENV="production" DB_USER="foo" DB_PASSWORD="bar" php artisan myCommand

Laravel 5.2 Testing : Test is not running

I have create a test via terminal with command :
php artisan make:test UserTest
Now i want to run the test with the following command :
vendor/bin/UserTest
But it returns
bash: vendor/bin/UserTest: No such file or directory
PHPunit is Installed. I have checked.
Am i missing something ?
Run tests with this command from Laravel root project directory:
vendor/bin/phpunit
If you want to run custom package tests, use:
vendor/bin/phpunit packages/name/package/

How do I remove old artisan command from Kernel in Laravel 5

I have created some Command files into my Laravel Application. Laravel version is 5.2. I set command like: get:email in the Command file. Also call the Command file into Kernel.php. After that I can see the artisan command list by typing the command php artisan list. as like as below:
//output
get:email
And I changed the command title get:email to get-bq:email. When I run the command php artisan get-bq:email -- its working nicely. Also I can see the list by typing the command php artisan list::
//output
get-bq:email
Issue / Problem: Both commands are working. But I won't to work with both of them. I have done the following things:
modified command file as well as command
run composer dump-autoload -o
run composer update
remove vendor and storage folder then run composer update again.
Still the old command is working into my system.
What I want: How May I remove my old commands from my Laravel(5.2) application?
Run these commands:
php artisan cache:clear
php artisan config:clear
These commands will clear app cache and config cache and recreate it.
I've had the same problem recently.
Repoeatedly tried
php artisan cache:clear
php artisan config:clear
and the cached Kernal command wouldn't clear.
In desperation i killed the queue worker terminal and restarted the queue with the command
php artisan queue:work
The issue stopped.

"There are no commands defined in the 'command' namespace." after running command:make in Laravel

Just like in title. I'm trying to run from artisan
php artisan command:make NameOfCommand
but all I see is
There are no commands defined in the "command" namespace.
Any idea what is this?
As the documentation says (Current version is 5.2 at this moment):
Once your command is finished, you need to register it with Artisan so
it will be available for use. This is done within the
app/Console/Kernel.php file.
in the Kernel.php file you must add:
protected $commands = [
Commands\NameOfCommand::class
];
(ref: https://laravel.com/docs/5.2/artisan#registering-commands)
You have misplaced the command it is
php artisan make:command NameOfCommand
and not
php artisan command:make NameOfCommand
If you have simply write php artisan within your command prompt it'll show you the list of commands over there have a look
In laravel 5.2 use php artisan make:console NameOfCommand

How to create a command for a Laravel 4 package?

The docs says that we can create a command for a package in Laravel 4.1 typing:
php artisan command:make AssignUsers --bench="vendor/package"
But it seems to not be working, I got the following error message:
[RuntimeException]
The "--bench" option does not exist.
Is there a way to create a command for a Laravel 4 package?
I used the standard artisan command to create a command into my package:
php artisan command:make CreateUsers \
--path="workbench/vendor/package/src/vendor/package"
After that, to make it available in the consumer application I had to add the following into my package's ServiceProvider (in the boot method):
$this->app->bind('vendor::command.user.create', function($app) {
return new UserCreateCommand();
});
$this->commands(array(
'vendor::command.user.create'
));
After that, everything will work fine.
when you run you will sse the list of arguments for make
php artisan command:make --help
you should see something like
Usage:
command:make [--command[="..."]] [--path[="..."]] [--namespace[="..."]] name
Arguments:
name The name of the command.
Options:
--command The terminal command that should be assigned.
--path The path where the command should be stored.
--namespace The command namespace.
--help (-h) Display this help message.
--quiet (-q) Do not output any message.
--verbose (-v|vv|vvv) Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
--version (-V) Display this application version.
--ansi Force ANSI output.
--no-ansi Disable ANSI output.
--no-interaction (-n) Do not ask any interactive question.
--env The environment the command should run under.
as you can see from that output there is no argument bench
the proper way to do it is
php artisan command:make AssignUsers
then go to /app/start/artisan.php and add the following line
Artisan::add(new AssignUsers);
then edit the generated file in /app/commands/AssignUsers.php
change the value of $name to AssignUsers
and you are done.

Categories