Laravel 5.1: Changing PHP version used by Artisan Facade - php

I have an application that will run an Artisan command via a controller:
Artisan::call('myCommand');
The problem is that my production server doesn't have their Terminal PHP version up to speed, so they needed to put in a fix for my running of composer and artisan commands ( I now use /usr/bin/php55 ).
Now, when I try to to call the Artisan command via my controller, I am getting this error:
Parse error: syntax error, unexpected 'class' (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' in on line 54
This error is due to the PHP version being wrong, which agrees with previous issues I have had on my production server.
Does anyone know how I can change the version of PHP used by the Artisan Facade? Preferably without changing any core Laravel code :)
Thanks

When you run a command via Artisan::call() you are not creating a separate process. The command code is executed with the same process that handles the request and uses the same PHP version. There is no way to make it use another PHP version when calling it via Artisan facade.
In order to use different PHP version you need to run the command in a separate process. You can use Symfony's Process class for that - it's bundled with Laravel, so there is no need to install anything.
This should work for you:
$process = new Process('/usr/bin/php55 artisan command:name');
$process->run();

Related

After Renamimg app name getting FatalThrowableError

I am using laravel-5.3. After renaming the app when I'm trying to start the server I'm getting the following error
[Symfony\Component\Debug\Exception\FatalThrowableError] Class
'App\Providers\AppServiceProvider' not found
What should i do? I am new at Laravel.
This is probably because you have your configuration cached. You can solve it with the artisan command 'config:cache':
php artisan config:cache
Before this, make sure that you have the correct namespaces in your application.

laravel artisan app:name resulted in syntax errors

I am using Laravel 5 on a shared host. I have installed it ok. However on running:
/usr/bin/php55-cli artisan app:name 247
the laravel install broke. I tracked it down to app.php and the new name caused syntax errors. I got it working again by using Linux to do a global replace changing it back from 247 to App.
Does anyone know why? And how can I get artisan to work properly?
Thanks
This is not Laravel nor artisan issue, but plain PHP syntax error.
PHP does not allow variable or class name to start with an integer. Same goes to namespaces. So your error comes from you app name being 247. First letter can not be an integer.

Php artisan not working (laravel 5.1)

Suddenly when i type php artisan or any artisan command
i seen this message
[ErrorException]
Trying to get property of non-object
I tried the following
1- php artisan clear-compiled
2- To delete vendor directory and use composer install Or composer update
3- clone a standard Laravel app and put my files app dir and my config
and use composer commands but with step the error has changed to be
[ErrorException]
Trying to get property of non-object
Script php artisan clear-compiled handling the post-install-cmd event returned with an error
[RuntimeException]
Error Output:
Any Suggestions ?
Thanks
If I understand well, you have this issue when you use your app files. It probably means that you have some problem in constructor - you try to run function and the object is not initialized. You should not set up things in constructors (look for example at your controllers) or you will get some "strange" errors and your artisan won't work
After navigation on my app i found the issue in my ServiceProviderClass boot() method in particular when comment one method get data according to subDomain name artisan worked well
Laravel Doc hint for this method
This method is called after all other service providers have been registered, meaning you have access to all other services that have been registered by the framework
for more read Laravel service provider

Laravel 4 Commands stopped working suddenly

Back from vacation, and when I'm trying to run one of my previously working command:
php artisan list
Throws me:
[root#api2]# php artisan list
{"error":{"type":"Symfony\\Component\\Debug\\Exception\\FatalErrorException","message":"Call to a member function getArgument() on a non-object","file":"\/var\/www\/html\/api2.alariscms.com\/vendor\/laravel\/framework\/src\/Illuminate\/Console\/Command.php","line":153}}
And I seriously cannot understand why this happens. I tried debugging the file that throws an error. It awaits argument:
InputInterface $input but it gets NULL
I don't know what can go wrong on a framework level to stop receiving the required object.
Any ideas where to start debugging from? Or I can reload configurations / update laravel via cmd?
Thanks
This is what I would do:
php artisan dump
composer dump-autoload
check for current Laravel version
and then go to that specific command and check for bug there.
Also, what kind of argument are you trying to pass to command ? Is that object - if so check where is implementation of that class ?

sf2 php command-line issues for deployment #OVH

Hi there,
I am facing a quite annoying issue.
Situation
I would like to deploy symfony2 application in production on mutualized servers of OVH (pro). I got shell access (ssh), my database works fine and my files are online.
Issue
I cannot manage to make any php command line work. That is, for all major commandline:
- updating web directory : php app/console assets:install web
- updating databases: php app/console doctrine:schema:update --force
- downloading composer: php -r "eval('?>'.file_get_contents('http://getcomposer.org/installer'));"
-etc...
I get parse errors such as:
syntax error, unexpected T_STRING, expecting T_CONSTANT_ENCAPSED_STRING or '(' in
or
Error in argument 1, char 2: option not found r (that one was for composer download)
it seems a pretty common pb, however I couldn't manage to fix it :/
Any hints welcome!
Thanks in advance,
Cheers
On ovh, you can choose witch php is used by altering the cmd line :
/usr/local/bin/php.ORIG.5_4 -> php.ORIG.5.4.6
/usr/local/bin/php.ORIG.5_3 -> php.ORIG.5.3.16
/usr/local/bin/php.ORIG.5_2 -> php.ORIG.5.2.17
/usr/local/bin/php -> php.ORIG.4
I had a simular problem with deploying symfony2 project. I`m not sure that this is the case here, but my problem was with the cache. For some of the symfony2 console commands it uses cached paths, and if you have changed the location of the project this could cause the problem. It uses a cached path when trying to delete the cache :D so my suggestion is to go and delete manually the cache i app/cache.
Hope i helped

Categories