I'm running php artisan tinker followed by App\Project::all(); but upon pressing enter, I just get redirected to my project directory as opposed to displaying all records in the database?
What am I doing wrong and how can I fix it?
I have php 7.3 on my machine installed via homebrew.
I have to add a config file.
nano ~/.config/psysh/config.php
<?php return [ 'usePcntl' => false,]; ?>
After doing this I am able to use tinker
Please remove the App.
Project::all()
Can you try this.
Related
I need to run this command when user change something in translation file
php artisan export:messages-flat
I need to add it in may controller
so I'm using this code
\Artisan::call('export:messages-flat');
but it return error saying that
The command "export:messages-flat" does not exist.
but when I
php artisan list
it's in the list
I also try to run other command
\Artisan::call('cache:clear');
and it works
this is the package I'm using link
kindly help me, sorry for may poor english
The package only allows you to run the commands from the CLI. You can see from the source code, they only register the Artisan commands if the application is running from the console.
As an alternative, you can call ExportLocalization::export()->toFlat() according to their documentation.
I am in a bit of a situation where I need to manually restart queues on linux/ubuntu based box and the proper approach I was told to follow is to use the screen command line application.
I am on Ubuntu 14.X and when I do an -ls command I can actually see the sessions running on the server. Below is a command I would run if I was outside screen session:
mycommandline$ php artisan queue:restart
Now the issue is that if from the -ls output I grab the session's port to include in the command I run I get the error below:
Cannot exec 'php artisan queue': No such file or directory
I also tried typing screen "php artisan queue:restart" and I keep getting the same issue.
I am not farmiliar at all with the screen program and any suggestions to point me to the right direction would be much appreciated.
Okay digging through google I came up with the command below. Given that I already had a session that was running I needed to make sure that I send my commands on that same session just to be sure. Below is what I ended up doing which does confirm that something is happenning within the screen session:
luyanda#devbox:~$ screen -d -r 19167 -p0 -x stuff "free -g; php artisan queue:restart"
Attaching from inside of screen?
As I am not seeing any visible issues I am convinced that this is what I needed to do given that my log file is updating as well it either means that the queues never stopped working or I managed to restart them.
What I am still interested to know is how I can actually see the output of the commands I send to my session else if I can rather pipe the output somewhere else.
Any thoughts?
I'm trying to write a command as a quickstart to build a project. The command asks for input for database details and then changes the .env file. The problem is that the command needs to do some Database queries afterwards, but the .env variables are not reloaded.
My question would be, is there a way to reload or override .env variables runtime. And if not, is there a way to call another Artisan command freshly, so framework bootstraps again?
In my command I tried doing $this->call('build:project') in my actual command, but even in the second call the variables are not reloaded.
Is there a way to achieve this without making the user manually call multiple commands?
Thanks!
i had the same problem with reloaded .env variables, and i fixed it with this command line which allow you to clear the configuration :
php artisan config:clear
Hope that helped. Regards.
Laravel uses config files which take data from .env file. So, what you can do is to override configuration values at runtime:
config(['database.default' => 'mysql']);
Try to clear cache it helped me (couldn't ssh into the server)
Is there a {app route}/bootstrap/cache/config.php file on the production server? Delete it.
This helped me
As OP I'm trying to bootstrap a Laravel project build by running console command and asking for the database credentials in the middle of the process.
This is a tricky problem and nothing I read was able to fix it : reset config, cache, Dotenv reload, etc... It seems that once the console command / operation is initialized the initial database connection is kept all over until the end.
The working solution I found is to bypass, after database modification are done, this cached state by using native shell exec command and passing the php artisan command as parameter :
passthru('php artisan migrate');
So, the order will be :
php artisan project:build (or whatever is your console command)
prompt the user for database credentials
replace values in .env file (your search & replace algorythm)
run php artisan config:cache
passthru('php artisan migrate'); ro run your migrations
shell_exec would do the same but in silent mode while passthru will return the output generated by console.
https://www.php.net/manual/en/function.passthru.php
Done successfully on Laravel 8.52
I want to select all data from 1 table in command prompt (not from browser) using Laravel framework. Is there anyone know what the good references is? please give me link, thankyou
You can create an Artisan Command.
Check the Laravel 5.0 docs:
http://laravel.com/docs/5.0/commands
Then, you can run you command. Example:
php artisan mycommand:list
Laravel 4.2:
http://laravel.com/docs/4.2/commands
You can run artisan commands from "cmd" (Windows). (Edit your environment variables first! Add you PHP path).
Try:
php artisan tinker
Then:
DB::table('users')->get()
when I trying to migrate something I get this error:
**************************************
* Application In Production! *
**************************************
Do you really wish to run this command?
Command Cancelled!
Im running a centOS 6.5 server without Plesk 12
Is there anyway to figure out what the error is or how to solve it?
Thanks
A bit late for answer but just for info purpose you can use php artisan migrate --force to avoid it OR in laravel 5.2 they are using a key env in config/app.php configure it to avoid this prompt
reference https://github.com/laravel/laravel/blob/master/config/app.php
Just use --force flag in production:
php artisan migrate --force
https://laravel.com/docs/6.x/migrations#running-migrations
Forcing Migrations To Run In Production
Some migration operations are destructive, which means they may cause
you to lose data. In order to protect you from running these commands
against your production database, you will be prompted for
confirmation before the commands are executed. To force the commands
to run without a prompt, use the --force flag.
Change your environment first from production to local . /bootstrap/start.php somewhere line no 26
$env = $app->detectEnvironment(array(
// find your machine name and replace mine
'local' => array('hassanjamal.local'),
));
I've just bumped into this problem as well. If you don't want to reconfigure your app (which is probably a good idea) hit 'Y' and then enter instead of just enter. It will go on even in production setting.
Simple,
$env = $app->detectEnvironment(function()
{
return 'development';
});
Good luck!