How to fix this error that pops up after migrations in Laravel - laravel

Am new to Laravel ,so been trying to do migrations and this error keeps popping up in the terminal
so after editing my .env file and trying to run php artisan migrate i get the error that i have attached below,i have tried to search the error around,but cant get any meaningful solution

You need to have the php-mysql extension installed on your machine.
You can install this extension with the following command:
sudo apt-get install php-mysql
Hope this helps! :)

Related

Laravel error - Class setEventDispatcher does not exist

Short version
I'm getting this error, when I run php artisan serve and visit my home page:
ReflectionException (-1)
Class setEventDispatcher does not exist
Details
Laravel version: 5.6.39
Environment: local
OS: macOS Mojave 10.14.2
It started, when I got an error using npm (in another project), so I reinstalled Node (this way).
After doing that, then this project (in question) couldn't be started. I was getting this error, when running php artisan serve:
dyld: Library not loaded: /usr/local/lib/libpng16.16.dylib with anything php related
Referenced from: /usr/local/bin/php
Reason: image not found
That error was resolved by updating and upgrading brew.
Then I was capable of starting the project (php artisan serve). But when I visit the home page, this error was shown:
ReflectionException (-1)
Class setEventDispatcher does not exist
If I follow the stack trace, then I can see that it was this line (from my homeController) that triggered the error:
if( ! Auth::check() ){
return view( 'pages.home' );
}
If I commented that out, then the same error occured from another place, where the Auth-module was being used.
Here's the stack trace:
Does anyone know how to resolve this? I can't find any promising results on Google, - and I have no idea why this happens... :-/
Addition1
I tried composer clear-cache and deleting the vendor-folder, and then doing a composer install and the problem still occured.
I also checked my Service Providers, as Marcus suggested, - but I don't really know what to look for in there. It all looks pretty regular (no fancy if-statements or anything).
Addition2
I realized, that I couldn't connect to my database using Sequel Pro. And it was because Brew had updated my MySQL-version from 5.5 to 8.0.
That was resolved by doing something along these lines (I did a bunch of stuff, so I might be missing a coulple of steps):
brew unlink mysql
brew install mysql#5.7
brew switch mysql 5.7.21
brew link mysql
and I could then verify the version with mysql --version. I also had some permission issues with that MySQL-version-change, but I'm emitting that, so this doesn't get too long.
Addition3
I tried disabling the Laravel Debugbar (by deleting it from composer.json, deleting composer.lock and vendor and then running composer install). And that fixed it!! ... But!
When I later tried to install Barryvdh's IDE Helper, then the exact same error came back!?
I performed these three steps, to install the IDE Helper (and re-introduce the error):
Run this command from the root of my directory: curl https://gist.githubusercontent.com/barryvdh/5227822/raw/4be028a27c4ec782965bb8f2fdcb4c08c71a441d/_ide_helper.php -o _ide_helper.php
Add these lines to app/Provider/AppServiceProvider.php:
...
if ($this->app->environment() !== 'production') {
$this->app->register(\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider::class);
}
Run this command: composer require --dev barryvdh/laravel-ide-helper
So I'm back at this error:
ReflectionException (-1)
Class setEventDispatcher does not exist
... The stack trace is identical to the one shown previously (sprung from Container.php).
Tried every solution, none of them worked.
Finally, i realised that when trying to upgrade php to 7.3.3 it was infact a network error that caused the fail. Read the logs, tried again, restarted valet and tried again.
It works now.
Upgrading to 7.3.3 was the solution indeed.
Thank you!
So this is what usually fixes it for me
Reinstall composer dependencies by removing vendor folder and composer.lock. Then run composer clear-cache and then composer install (this is usually the problem)
Check that all service providers are imported correctly in app.php under directory config
Make sure that your service providers are not importing something that does not exist, for example if you register a service provider in production but is only installed as dev:
if (env('APP_DEBUG')) {
$app->register(Barryvdh\Debugbar\LumenServiceProvider::class);
}
If you use valet, I solved it running
valet restart and all works fine.
cheers!
The fix for me was to update PHP to 7.3.3 and then restart valet. Apparently this was a bug with php 7.3
https://github.com/laravel/framework/issues/27052
Hope this helps
I got some idea... I've just run into this problem after reconfiguring my apache virtual host ports, so I restarted apache/httpd again, and the problem went away. Might it be related with the server environment?
I am facing the same issue in mac book pro. My system configuration is PHP 7.3, MySQl and I use SQL Pro. I have implemented all the above methods but nothing gets worked.
The issue is still a mystery for me but for temporary I have solved this issue using
artisan command as bellow.
php artisan serve
Its Allow me to run the project on http://localhost:8000
Hope this can help to solve this issue.
Try to restart PHP. When I reboot my Mac, then this happens. After restarting PHP everything starts to work.
sudo brew services restart nginx

how to fix error laravel 5.2 "failed to open stream: No such file or directory" without composer

I've got this error in my laravel 5.2 project who hosted in debian linux
Warning: require_once(/home/u706561288/public_html/sap/vendor/composer/autoload_real.php): failed to open stream: No such file or directory in
/home/u706561288/public_html/sap/vendor/autoload.php on line 5
Fatal error: require_once(): Failed opening required '/home/u706561288/public_html/sap/vendor/composer/autoload_real.php' (include_path='.:/opt/alt/php70/usr/share/pear') in
/home/u706561288/public_html/sap/vendor/autoload.php on line 5
so many forum like stackoverflow tell me to using php artisan "composer update" but
unfortunately my hosting package not available to composer instalation
please tell me how to fix this problem
I suggest that you test these steps
On the Localhost, run these two commands (composer update and composer dump-autoload)
Re-upload the entire project on the server
Also, if the problem is not resolved, you can delete the ‍Vendor folder and the composer.lock file and run the composer install command and Re-upload the entire project again.
When the hosting service or some PC does not allow to install Composer and appears error like in my case, follow these steps:
Delete all laravel project in hosting service. I recommend to use smartftp for good speed file access and tracked action.
Back to our localhost project and run composer install --no-scripts command and then composer clearcache.
Reupload all laravel project.
Don't forget to configure .env file.
I hope this can help with the same problem in future.
I had the same error while back, what I did to solve it was. I delete all the vendor folder from the root project then install it back by executing composer install
delete the ‍Vendor folder and the composer.lock file and run the composer install command and Re-upload the entire project again
this helped me
If anyone still facing the issue after deleting the vendor directory and did composer install try to update your composer by composer selfupdate then do the same install process.

Cannot install Laravel correctly

I followed all the instruction by installing composer and then Laravel. Also I did everything what was shown in laracast series for installing Laravel and composer.
BUT I have some problems and I cannot solve them:
I don't have Vendor folder in my Laravel app folder
I cannot launch command 'composer artisan' as it says that
[Symfony\Component\Console\Exception\CommandNotFoundException]
Command "artisan" is not defined"
"php artisan" also doesn't work
All the answer in the web I have already tried to resolve my problems but nothing worked for me
Please, tell me, how can I install Laravel correctly and use it without errors
Run composer install or composer update. This will create the vendor folder and download all the dependent modules as mentioned in the composer.json
I want to add some more details which are asked but not clearly answered.
You did not install the composer dependencies. Try composer install.
It is not composer artisan. If you execute that command, you say hey composer! run your artisan command. And it says "Command "artisan" is not defined."
It is php artisan. But if you don't run composer install, php artisan will not work either. Because you are missing Symfony Console Component in your project (not the one used by composer) as well as a complete Laravel installation. Both will also be installed by the composer install command.
Well. I've solved my problem. As I mentioned before I had tried all the answer in the web but nothing had helped me. So then I just deleted my laravel project and ran this command
sudo apt-get upgrade
After some time packages were upgraded and I created new Laravel project. And Laravel started working perfectly! So in any incomprehensible situation do apt-get upgrade :))

PDOException could not find driver

I'm getting this error when i try to migrate. Im trying to run my project on postgres on MAC OS. Any suggestion how can i do this? I uncomment this in php.ini
but i nothing happend.
extension=php_pdo_pgsql.dll
extension=php_pgsql.dll
add this line in php.ini
extension=pdo_mysql.so
and then install the PDO by running following command:
sudo apt-get install php-mysql
EDIT
and also try to restart your computers sometimes it happens that restarting apache did not reloads the configuration

Laravel composer signal "11" error symfony osx

Anything I try to execute in Laravel, even minor files locally gives this message in composer:
[Symfony\Component\Process\Exception\RuntimeException]
The process has been signaled with signal "11".
Using OSX 10.7.5
Any help appreciated, as always.
For example :
composer update
typed in terminal retrieves the error message above
Make sure to check your composer cache folder has the right permissions for all files and folders.
If you ever ran composer as sudo or root then these cache folders could have the wrong root permissions.
Look at all the files and folders inside:
ll ~/.composer/cache/
Make sure you have proper permissions to write files in app/storage directory. And you can always use the following method of installation.
cd /your/app/directory
git clone https://github.com/laravel/laravel.git .
composer install
I got this error due to circular dependency on AppServiceProvider (when 2 services depend on each other). As the error does say much it took me a loooong time figure it out :/
Try:
Reinstall or upgrade PHP (Cli)
Make sure your .composer directory permission
This error message from laravel artisan is caused by Composer command error, you can try the same way from using command like:
composer dump-autoload -o
It should also cause error relating from aristan optimize command which be trigger from post-update-cmd" in composer.json.
In my case, the error is segment fault via Cygwin PHP so that I change to use XAMPP PHP to run it and it worked.
Try to run thin command
composer dump-autoload
I eventually solved this by employing a freelancer who was excellent and very knowledgeable.
First needed to update OSX with Maverick (free) - (I had to change my hard drive to do this!)
Then needed to download xcode
Composer should then function, you may need a new installation of laravel
Hope that helps someone!

Resources