Laravel/Lumen - missing commands in Artisan console - php

I have a problem with runing Laravel's Artisan. There are most of the commands missing. Everything worked fine till the last composer/code update.
For an example if I write php artisan migrate, I get following error: Command "migrate" is not defined.
Below is an example of output that I get by typing php artisan.
Laravel Framework version Lumen (5.1.6) (Laravel Components 5.1.*)
Usage:
command [options] [arguments]
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under.
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Available commands:
help Displays help for a command
list Lists commands
serve Serve the application on the PHP development server
schedule
schedule:run Run the scheduled commands
Does anyone have any ideas how to fix this?

It seems there was a problem with composer. Somehow composer.lock got into git ignore list and libraries used on production were different than the ones used in development.

The syntax has changed to php artisan make:migration.
You can see a full list of commands by running php artisan list

Related

How can I run php artisan serve using .env.production?

I have a Laravel Web Application, and it works just fine locally, using a local .env file that references the local database.
I have the same Laravel Web Application deployed in production, where I find a .env, which is different from the one that I use locally.
Both the scenarios work perfectly, but when I wanted to perform a test with the remote database (that I can access from my local IP address), I copied the remote .env and renamed it .env.production.
How can I run the php artisan serve using the .env.production ?
The php artisan serve help states that adding a --env parameter should make the trick, as you can see from the command result below
php artisan serve --help
Description:
Serve the application on the PHP development server
Usage:
serve [options]
Options:
--host[=HOST] The host address to serve the application on [default: "127.0.0.1"]
--port[=PORT] The port to serve the application on
--tries[=TRIES] The max number of ports to attempt to serve from [default: 10]
--no-reload Do not reload the development server on .env file changes
-h, --help Display help for the given command. When no command is given display help for the list command
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
but the command php artisan serve --env=production still loads the local database.
What am I doing wrong ?
After some tests I found a working solution in a Laracast Forum, giving credits to a Laravel.io post that consists into running the following command:
APP_ENV=production php artisan serve
This causes the .env.production to be loaded and used by the local server, as needed.
I post this here hoping it will be useful to someone in my same condition.

How can I debug php bin/console make:migration command freezing?

I am developing a web app using Symfony. I have successfully been using console commands fine with my project. I must have done something because now the command php bin/console make:migration freezes, with no output even in verbose mode. The command php bin/console make:entity works fine and makes me think there is something wrong with the database connection. Steps I have tried:
Make sure the DB version is present in .env file.
Restarted server
Deleted cache
Deleted entire project and cloned from git and ran composer install
The app still works as intended, but I cannot make a migration. The command simply hangs with no errors. Any suggestions on how to debug this?
You can add different levels of verbosity using the parameter "-v", as the Console list explains:
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Launch php bin/console make:migration -vvv to debug and see why it hangs.
It is not frozen. In this update, they have forgot to print the message.
The message is "Are you sure you wish to continue? y/i"
If you enter y and hit enter it will be continued.

Not enough arguments (missing: "key"). in laravel php artisan cache:forget

When i try to remove my all cache file from laravel 5.5 project i got some error during run this command
php artisan cache:forget
Not enough arguments (missing: "key").
use command php artisan cache:forget -h for see list Arguments and options.
this is list agruments and option of cache:forget command larvel 5.4
Arguments:
key The key to remove
store The store to remove the key from
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--env[=ENV] The environment the command should run under
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
if you want remove all cache file you can run this command
php artisan cache:clear
php artisan config:cache
and see more artisan command
php artisan list
You can use
php artisan cache:clear
after key generate with this command:
php artisan key:generate
For removing a entire Cache you can use Cache::flush();
For removing a key from Cache u can use Cache::forget('key') programmatically.
You can also use artisan console
php artisan cache:forget key="yourkey"
Hope this helps

Codeception `build -c` option removed in 2.2?

I get an alert. Tests are failing. And not just on my last commit... But on every branch. So something must be wrong with the automated testing. Right?
And here's the message:
Failing command: php /var/www/codecept.phar build -c /var/www/protected/tests/
Exit code: 1
Output:
[Symfony\Component\Console\Exception\RuntimeException]
The "-c" option does not exist.
OK. But it works locally... Hmm... Let's check if I'm running the same version.
I'm not:
$ codecept -v
Codeception version 2.1.9
$ wget http://codeception.com/codecept.phar
$ php ./codecept.phar -v
Codeception version 2.2.1
So I'm running 2.1.9. And my tests pass. Test continuous environment is getting the latest version 2.2.1. And it fails.
Let's check out the help for 2.1.9:
$ codecept help build
Usage:
build [options]
Options:
-c, --config[=CONFIG] Use custom path for config
-h, --help Display this help message
-q, --quiet Do not output any message
<snip>
There's the option. -c, --config.
And now let's look at 2.2.1:
$ php ./codecept.phar help build
Usage:
build
Options:
-h, --help Display this help message
-q, --quiet Do not output any message
<snip>
Hey! There is no longer a -c option.
What can I do to point codecept at the config directory?
https://github.com/Codeception/Codeception/issues/3173
Something is wrong with phar files of 2.2.1 version, I can only recommend to use Codeception installed with composer until that issue is fixed.

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