artisan commands not working mac with docker - php

I have laraval running on my macbook (macOs ventura 13.1) with docker. It works perfect, but i cant seem to run artisan commands in the terminal.
If i check the php version with php -v, it says php: command not found. When i try to add a controller, i also get this error:
Error
What could be the problem?

Related

Laravel Artisan error: Target class does not exist

Once our Laravel app is deployed to hosting (AWS Elastic Beanstalk) it's impossible to run php artisan from the ssh command prompt. Every time results in the following error:
In Container.php line 879:
Target class [request] does not exist.
In Container.php line 877:
Class "request" does not exist
Even just running php artisan without any parameters results in the same error. Locally everything is fine.
Strangely AWS runs certain bash php artisan commands as part of postdeploy hooks which work fine during deployment (eg. artisan config:cache). They work fine, but even if I disable that bash script and try to run those commands manually via ssh after deploy, I get the same error. Very confusing.
It's as if there's something happening after deployment that's breaking php artisan.
We're running PHP 8.0.18 and Laravel 9.0.1. I've tried composer dump-autoload, but I still get the same error while that's running.
Where would be the right place to start looking for the cause of this error message?

Laravel Artisan command for soap call "Class 'SoapClient' not found"

I have an artisan command where I do a soap call.
So I use the SoapClient
use SoapClient;
When I test run my command from an url like this:
Route::get('test-command', function() {
Artisan::call('updateRegisterLogs');
});
Everything works great!
Now when I try to run it with artisan on my linux server to test the command to create a cronjob I get the following error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Class 'SoapClient' not found
The weird thing is I even get this error when I try a simple php artisan to see a list of all my commands.
Why does my artisan break from this? My code works fine but artisan doesn't.
The PHP version and also the CLI ini file could be different from the web one and when running command with artisan you are using the php cli.
Check with
php -r "echo phpinfo();"
If your php cli has soap enabled.

symfony - 'bin' is not recognized as an internal or external command

I am trying to run a symfony command via the command line. On writing the below command
bin/console doctrine:database:create
it outputs an error
'bin' is not recognized as an internal or external command,
operable program or batch file.
php is installed on my machine and configured in environment variables but I am getting that error. Please what could be wrong?
This is a Linux like command. Obviously you are coming from Windows system:
php bin\console doctrine:database:create
Pro tip: you can shortcut commands as long as the shortcut is unique:
php bin\console doc:dat:cr
Make sure you cd to the app's directory before running the command too.

Laravel server not starting

I have a fresh installed laravel app and when i run php artisan serve it shows me the server information but when i go to that server it gives a cant be reach error. I am not running Vagrant just MAMP but it used to work before. I did tried to install Vagrant in the past and it didn't work that is why i came back to MAMP only. I read something about generating a key with php artisan key:generate which didn't work. Any help is appreciated.
This is the command I am using and the result
$ php artisan serve
Laravel development server started: <http://127.0.0.1:8000>
try to uninstall the antivirus if you have one ,in my case i uninstall avast ,reboot OS and it works for me .

Running laravel migration on heroku server

I have a production server, and i have deployed the code into the server, but when i try to migrate the databse with this command :
heroku run php artisan
This what i have returned
Running php artisan on [app-name] ... up, run.3899
bash: php: command not found
And the BUILDPACK_URL in the Config Vars set to
https://github.com/heroku/heroku-buildpack-php
any help please :) ?

Categories