Laravel schedule command with cron - php

I have command log:demo and I successfully run it from ssh console with command: php artisan log:demo.
Now I need to create cron job and its ok but when cron starts a command I get in laravel.log:
> [2016-03-22 21:45:01] local.ERROR: exception 'ErrorException' with message 'Invalid argument supplied for foreach()' in /home/agroagro/public_html/vendor/symfony/console/Input/ArgvInput.php:283
Stack trace:
#0 /home/agroagro/public_html/vendor/symfony/console/Input/ArgvInput.php(283): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/home/agroagro/...', 283, Array)
#1 /home/agroagro/public_html/vendor/symfony/console/Application.php(790): Symfony\Component\Console\Input\ArgvInput->hasParameterOption(Array)
#2 /home/agroagro/public_html/vendor/symfony/console/Application.php(117): Symfony\Component\Console\Application->configureIO(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#3 /home/agroagro/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(107): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#4 /home/agroagro/public_html/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#5 {main}
Why does manually calling command work, but cron does not?

does the cron run with the same user and privileges as you do?
is the bash the same? check php version...
that was the problems on my server...

Related

Trying to upgrade to laravel 5.3 but I keep seeing error `Call to undefined method Illuminate\Auth\Access\Gate::abilities()`

I am trying to upgrade laravel 5.3 from 5.2 but I keep seeing these two errors in my log file:
Symfony\Component\Debug\Exception\FatalErrorException: Uncaught Error: Call to undefined method Illuminate\Auth\Access\Gate::abilities() in /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
And this one:
Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Log\Writer::setHandlers() in Command line code:1
Full stack outputs:
[2020-08-13 08:26:58] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught Error: Call to undefined method Illuminate\Auth\Access\Gate::abilities() in /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
Stack trace:
#0 Command line code(1): Illuminate\Support\Facades\Facade::__callStatic('abilities', Array)
#1 {main}
thrown in /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:237
[2020-08-13 08:26:58] local.ERROR: Symfony\Component\Debug\Exception\FatalThrowableError: Call to undefined method Illuminate\Log\Writer::setHandlers() in Command line code:1
Stack trace:
#0 [internal function]: VscodeLaravelExtraIntellisenseProvider->boot()
#1 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Container/Container.php(508): call_user_func_array(Array, Array)
#2 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(769): Illuminate\Container\Container->call(Array)
#3 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(752): Illuminate\Foundation\Application->bootProvider(Object(VscodeLaravelExtraIntellisenseProvider))
#4 [internal function]: Illuminate\Foundation\Application->Illuminate\Foundation\{closure}(Object(VscodeLaravelExtraIntellisenseProvider), 2)
#5 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(753): array_walk(Array, Object(Closure))
#6 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/BootProviders.php(17): Illuminate\Foundation\Application->boot()
#7 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\BootProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /Users/rohan0793/Code/poptin_v3/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(113): Illuminate\Foundation\Console\Kernel->bootstrap()
#10 Command line code(1): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
I have no idea where these are coming from and how to resolve them.
UPDATE: I see these errors every minute at 41 secs. Example 13:35:41
But according to my crontab in homestead, I don't have any crons scheduled
UPDATE 2: https://github.com/illuminate/auth/blob/5.5/Access/Gate.php the abilities method is present in 5.5. But I am still at 5.3. Weird but I don't know what is calling that code already. Maybe a third party package.
https://marketplace.visualstudio.com/items?itemName=amiralizadeh9480.laravel-extra-intellisense
This VS Code extension was causing the 2 errors, and it was trying to compile something every minute and hence it was very confusing and felt like a cron job running in the background.
Try to find on official documentation for upgrade guide. They cover a lot of issues and maybe you find yours. It's a very specific issue and you are missing something in your code, but from a question, we can't know. https://laravel.com/docs/5.3/upgrade#upgrade-5.3.0
Also try Rector for upgrade or any issue after upgrade https://github.com/rectorphp/rector

Fatal error: Uncaught ReflectionException: Class config does not exist

I'm working on an e-commerce project on Laravel 5.8, but since I accidently ran "laravel new" command on the project's folder I get this error when I'm trying to launch the project on a local server:
Fatal error: Uncaught ReflectionException: Class config does not exist in C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php:788
Stack trace:
0 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(788): ReflectionClass->__construct('config')
1 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(667): Illuminate\Container\Container->build('config')
2 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(615): Illuminate\Container\Container->resolve('config', Array)
3 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(767): Illuminate\Container\Container->make('config', Array)
4 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php(1227): Illuminate\Foundation\Application->make('config')
5 C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Log\LogManager.php(417): Illuminate\Container\C in C:\wamp64\www\e-commerce\vendor\laravel\framework\src\Illuminate\Container\Container.php on line 788"
The error on line 788 refers to that portion of code:
$reflector = new ReflectionClass($concrete)
This happened after I cloned my repo from Github. Now for every project that I try to run on a local server I get this error.
I tried "composer install", "composer update", "composer dump-autoload" but they all give the same error with this line at the end:
"Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255".
I checked the .env file to see if there was a namespace issue too, but there's none of it.
Thank you in advance for your help.
Try to remove de files in:
cd bootstrap/cache/
rm -rf *.php
In this directory are the file that initializes the structure, cache directory that contains structure-generated files for performance optimization, such as files and route cache services.
You may check the following items
Check whether your APP_NAME has space. If space is there, use it in quotes.
Delete everything from bootstrap/cache/ folder.
run composer dump-autoload
Hope it will work
I tried #gulCunha 's answer and it worked.
After that, you have to run composer update in order to create a new composer.lock and php artisan config:cache after that and you should be good to go.
Did you change the .env file,mistakenly I have added a "APP_NAME=aaa aa " with spaces, then checked every where, after that APP_NAME= changed without spaces, now working charm.
I was creating a new Laravel 9 project with composer and got the same error.
Fatal error: Uncaught ReflectionException: Class "config" does not exist in .../vendor/laravel/framework/src/Illuminate/Container/Container.php:875
Stack trace:
#0 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(875): ReflectionClass->__construct('config')
#1 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\Container\Container->build('config')
#2 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve('config', Array, true)
#3 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Foundation\Application->resolve('config', Array)
#4 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make('config', Array)
#5 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(1415): Illuminate\Foundation\Application->make('config')
#6 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(515): Illuminate\Container\Container->offsetGet('config')
#7 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(566): Illuminate\Log\LogManager->getDefaultDriver()
#8 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\Log\LogManager->parseDriver(NULL)
#9 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(702): Illuminate\Log\LogManager->driver()
#10 .../vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(274): Illuminate\Log\LogManager->log('error', 'substr(): Argum...', Array)
#11 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(367): Illuminate\Foundation\Exceptions\Handler->report(Object(TypeError))
#12 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->reportException(Object(TypeError))
#13 .../artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#14 {main}
Next Illuminate\Contracts\Container\BindingResolutionException: Target class [config] does not exist. in .../vendor/laravel/framework/src/Illuminate/Container/Container.php:877
Stack trace:
#0 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(756): Illuminate\Container\Container->build('config')
#1 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(855): Illuminate\Container\Container->resolve('config', Array, true)
#2 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(692): Illuminate\Foundation\Application->resolve('config', Array)
#3 .../vendor/laravel/framework/src/Illuminate/Foundation/Application.php(840): Illuminate\Container\Container->make('config', Array)
#4 .../vendor/laravel/framework/src/Illuminate/Container/Container.php(1415): Illuminate\Foundation\Application->make('config')
#5 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(515): Illuminate\Container\Container->offsetGet('config')
#6 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(566): Illuminate\Log\LogManager->getDefaultDriver()
#7 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(119): Illuminate\Log\LogManager->parseDriver(NULL)
#8 .../vendor/laravel/framework/src/Illuminate/Log/LogManager.php(702): Illuminate\Log\LogManager->driver()
#9 .../vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(274): Illuminate\Log\LogManager->log('error', 'substr(): Argum...', Array)
#10 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(367): Illuminate\Foundation\Exceptions\Handler->report(Object(TypeError))
#11 .../vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\Foundation\Console\Kernel->reportException(Object(TypeError))
#12 .../artisan(37): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#13 {main}
thrown in .../vendor/laravel/framework/src/Illuminate/Container/Container.php on line 877
Script #php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 255
But this time it was not about the cache. Regardless of what the errors suggest, the problem was actually caused by the following lines found in vendor/vlucas/phpdotenv/src/Util/Str.php
$converted = $encoding === null ?
#\mb_convert_encoding($input, 'UTF-8') :
#\mb_convert_encoding($input, 'UTF-8', $encoding);
It actually occurred as I didn't have Multibyte String enabled when I built my PHP binaries. After rebuilding PHP with --enable-mbstring, the problem went away.
Make sure your .env file is the exact same as in your local environment. Make sure that the values on your .env file don't have spaces. Those that have spaces should be wrapped in quotes
I had a similar problem. Here is how I fixed it.
It started when I installed Toastr in my config/app.php providers.
I had failed to add the trailing ",".
Hence the problem.
Solution:
Check the last package you installed.
Check if you have added it correctly in the service providers.
You should run 'composer update' command, and then 'php artisan optimize' to clear the config cache and routes.

array_merge(): Argument #2 is not an array after adding class into providers

I am using pbmedia/laravel-ffmpeg as soon as I installed and added the providers and alias, it shows me the following error. This code was simply working on another machine
array_merge(): Argument #2 is not an array
I have tried the following things
Composer update/ and Fresh install
Cleaning the bootstrap/cache/
Checked the config file for laravel-ffmpeg it's there and fine
Publish the config file using the artisan CLI tool: php artisan vendor:publish --provider="Pbmedia\LaravelFFMpeg\FFMpegServiceProvider"
Here is the portion from laravel.log when I tried to run.
[2019-06-19 00:34:40] local.ERROR: ErrorException: array_merge(): Argument #2 is not an array in /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php:59
Stack trace:
#0 [internal function]: Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'array_merge(): ...', '/Users/damanmok...', 59, Array)
#1 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Support/ServiceProvider.php(59): array_merge(Array, 1)
#2 /Users/damanmokha/edetyv2/vendor/pbmedia/laravel-ffmpeg/src/FFMpegServiceProvider.php(25): Illuminate\Support\ServiceProvider->mergeConfigFrom('/Users/damanmok...', 'laravel-ffmpeg')
#3 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(565): Pbmedia\LaravelFFMpeg\FFMpegServiceProvider->register()
#4 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(74): Illuminate\Foundation\Application->register(Object(Pbmedia\LaravelFFMpeg\FFMpegServiceProvider))
#5 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(540): Illuminate\Foundation\ProviderRepository->load(Array)
#6 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\Foundation\Application->registerConfiguredProviders()
#7 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(203): Illuminate\Foundation\Bootstrap\RegisterProviders->bootstrap(Object(Illuminate\Foundation\Application))
#8 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(267): Illuminate\Foundation\Application->bootstrapWith(Array)
#9 /Users/damanmokha/edetyv2/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(113): Illuminate\Foundation\Console\Kernel->bootstrap()
#10 /Users/damanmokha/edetyv2/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#11 {main}
if I don't add these providers it works fine, but then I am not able to use ffmpeg without that.
Laravel Version 5.3
pbmedia/laravel-ffmpeg 1.3
php version: 7.1

Getting a blank screen with no errors using Laravel 5.4

I am following a tutorial and my screen turned blank with no error messages. I looked in laravel.log and got this errors, but am unsure how to fix it.
Here is the error from the log file.
2017-04-10 14:30:40] local.ERROR: Symfony\Component\Console\Exception\RuntimeException: The "--resources" option does not exist. in /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Input/ArgvInput.php:219
Stack trace:
#0 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Input/ArgvInput.php(155): Symfony\Component\Console\Input\ArgvInput->addLongOption('resources', NULL)
#1 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Input/ArgvInput.php(84): Symfony\Component\Console\Input\ArgvInput->parseLongOption('--resources')
#2 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Input/Input.php(63): Symfony\Component\Console\Input\ArgvInput->parse()
#3 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Command/Command.php(220): Symfony\Component\Console\Input\Input->bind(Object(Symfony\Component\Console\Input\InputDefinition))
#4 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/laravel/framework/src/Illuminate/Console/Command.php(167): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Illuminate\Console\OutputStyle))
#5 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Application.php(826): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#6 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Application.php(190): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Routing\Console\ControllerMakeCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#7 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/symfony/console/Application.php(121): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#8 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(123): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#9 /Users/aaronmk2/Desktop/CodingDojo/php/Todos/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#10 {main}
From the log file the error is telling you that the --resources option does not exists on the command php artisan make:controller.
You have to call that command with the option --resource (singular one), i.e.:
php artisan make:controller PhotoController --resource

exception 'PDOException' with message 'could not find driver' SQLSRV Laravel Artisan CLI

I am running php 5.5 on a Windows Server 2008. I am using the Laravel 4.0 framework for the application. I am connecting to a SQL SRV database via PDO, when executed via http there is no issue, connections are made data is called and updated without issue.
However when calling a command from Artisan (Laravel's CLI tool) I get the following error in the log:
log.ERROR: exception 'PDOException' with message 'could not find driver' in C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php:47
Stack trace:
#0 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\Connectors\Connector.php(47): PDO->__construct('sqlsrv:Server=H...', 'xxxxxx', 'xxxxxx', Array)
#1 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\Connectors\SqlServerConnector.php(29): Illuminate\Database\Connectors\Connector->createConnection('sqlsrv:Server=H...', Array, Array)
#2 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\Connectors\ConnectionFactory.php(41): Illuminate\Database\Connectors\SqlServerConnector->connect(Array)
#3 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(128): Illuminate\Database\Connectors\ConnectionFactory->make(Array, 'sqlsrv')
#4 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(64): Illuminate\Database\DatabaseManager->makeConnection('sqlsrv')
#5 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(242): Illuminate\Database\DatabaseManager->connection()
#6 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(206): Illuminate\Database\DatabaseManager->__call('table', Array)
#7 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Support\Facades\Facade.php(206): Illuminate\Database\DatabaseManager->table('bb_job_details')
#8 C:\inetpub\MBSWeb\postsrch\app\models\Job.php(214): Illuminate\Support\Facades\Facade::__callStatic('table', Array)
#9 C:\inetpub\MBSWeb\postsrch\app\models\Job.php(214): Illuminate\Support\Facades\DB::table('bb_job_details')
#10 C:\inetpub\MBSWeb\postsrch\app\models\Cron.php(18): Job::getJobDetailsByStatus()
#11 C:\inetpub\MBSWeb\postsrch\app\controllers\ApplicantController.php(14): Cron::ChangePostingJobStatus()
#12 C:\inetpub\MBSWeb\postsrch\app\commands\GetApplicantsCommand.php(45): ApplicantController->index()
#13 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Console\Command.php(108): GetApplicantsCommand->fire()
#14 C:\inetpub\MBSWeb\postsrch\vendor\symfony\console\Symfony\Component\Console\Command\Command.php(244): Illuminate\Console\Command->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#15 C:\inetpub\MBSWeb\postsrch\vendor\laravel\framework\src\Illuminate\Console\Command.php(96): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#16 C:\inetpub\MBSWeb\postsrch\vendor\symfony\console\Symfony\Component\Console\Application.php(897): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 C:\inetpub\MBSWeb\postsrch\vendor\symfony\console\Symfony\Component\Console\Application.php(191): Symfony\Component\Console\Application->doRunCommand(Object(GetApplicantsCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#18 C:\inetpub\MBSWeb\postsrch\vendor\symfony\console\Symfony\Component\Console\Application.php(121): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#19 C:\inetpub\MBSWeb\postsrch\artisan(59): Symfony\Component\Console\Application->run()
#20 {main} [] []
[2014-03-23 22:53:13] log.ERROR: exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined function Symfony\Component\Console\mb_detect_encoding()' in C:\inetpub\MBSWeb\postsrch\vendor\symfony\console\Symfony\Component\Console\Application.php:721
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleShutdown()
#1 {main} [] []
The PDO SQLSRV lib is installed, see the below screenshot of the phpinfo(), and as I've already said I can connection without issue when using the application via http;
Why is the PDO connection working fine via http but not in CLI? Please note I'm using the exact same set of code, one is called from a Laravel controller, the other from a Laravel command.
php cli and php cgi use different php.ini files. Try php -i | grep pdo to see if pdo is installed for your cli, see php -i | grep "Loaded Configuration File"
The answer above is correct, but just to clarify:
Open your console and execute:
php -i | grep "Loaded Configuration File"
That will give you the folder directory where you php-cli.ini is (Laravel Commands use a different php.ini than the one used by HTTP requests)
Go to that file, and make sure it has this:
extension=php_pdo_mysql.dll
Restart your server and try again. That worked for me, hope it helps.

Categories