Someone?
php artisan returns SQLSTATE[HY000] [2002] No such file or directory
Hello.
I've recently noticed that I just can't even run php artisan on my local machine without the VM being on.
I run php artisan and I get
SQLSTATE[HY000] [2002] No such file or directory
When I try to deploy my code I just can't deploy it because it always returns that error when I try to deploy it from my git repository.
Why is that happening? I'm just trying to run the normal php artisan without ANY attempt to touch the DB with some command. That's super weird!
Hi,
Did you use any database ?
@kossa what do you mean?
Can you paste the content of routes.php I thing you're calling you database with a model
@kossa do you mean that I somehow invoke the database in my routes.php file?
Here's the file:
<?php
$r = app('router');
$r->group(['prefix' => 'v1'], function ($r) {
$r->group(['namespace' => 'Auth'], function ($r) {
// registration and confirmation routes
$r->post('users', 'AuthController@register');
$r->get('confirm/{token}', 'AuthController@confirm');
// login route
$r->post('authenticate', 'AuthController@authenticate');
// password route
$r->put('users/{user_id}/change-password', 'PasswordController@changePassword');
$r->post('password/reset', 'PasswordController@postEmail');
$r->post('password/reset/{token}', 'PasswordController@postReset');
});
// user routes
$r->get('users/{user_id}', 'UsersController@show');
// profile routes
$r->put('users/{user_id}/profiles', 'ProfilesController@update');
$r->get('users/{user_id}/profiles', 'ProfilesController@show');
// tags routes
$r->get('tags', 'TagsController@index');
$r->get('tags/{tag_id}', 'TagsController@show');
$r->get('users/{user_id}/tags', 'TagsController@usersTags');
$r->post('tags', 'TagsController@store');
$r->put('tags/{tag_id}', 'TagsController@update');
$r->put('users/{user_id}/tags', 'TagsController@subscribe');
// ... Some more which looks pretty much the same
Exactly you should check .env file I'm sure here you access to a database, and something wrong ;)
@kossa Hey. I've just checked my routes.php file and even if I comment everything out I get that error.
However, when I try to set the DB connection to SQLITE and create an example database.sqlite file it all works.
I just don't understand why do I need the DB connection just to run php artisan? I don't get it...
It does checks on the DB connection/table. This has been like this for years.
How do you explain that if I start a new laravel project I can run php artisan even without configuring a database?
@kfirba This will most likely be the one
$r->post('authenticate', 'AuthController@authenticate');
I think I found a solution for your case, please check http://stackoverflow.com/questions/19475762/setting-up-laravel-on-a-mac-php-artisan-migrate-error-no-such-file-or-directory
If you want to do commands from your local machine - change the DB_HOST to 192.168.10.10 (for Homestead).
@bashy I just want to run the standard php artisan command. I can't even do that.
The route you mentioned isn't making any problems. I tried to comment out my WHOLE routes.php file and then run php artisan and still got that error.
@kossa the link was describing an issue where the user tried to use php artisan migrate which hits the DB and then got the error. In my case even just by typing php artisan I get that error.
I can't remember what it is but there's something that uses the DB connection.
@kfirba if you using lampp as a local server then you can include 'unix_socket' =>'/opt/lampp/var/mysql/mysql.sock' on you database confguration file or path to mysql socket.
just go to the config folder and then database.php and 'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'laraveltest2'),//here your database name 'username' => env('DB_USERNAME', 'root'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ], Actually Laravel need database connection and after that your composer will work. If you install composer globally than it should work.
Please or to participate in this conversation.