System: Ubuntu 18.10 PHP 7.2 Homestead - virtualbox
I get the following error when I try to execute any php artisan commands outside of the vm.
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = on
c_db and table_name = permissions and table_type = 'BASE TABLE')SQLSTATE[HY000] [2002] No such file or directory
I have followed recommendations listed in other questions with similar issues. Changing the DB_HOST from localhost
from/to 127.0.0.1
will fix the issue but create other problems. I am unable to run phpunit tests and the site will not load for me.
Previously I was getting a permissions table not found
error and corrected for it by adding a check for the table in my AuthServiceProvider.
public function boot(GateContract $gate)
{
$this->registerPolicies();
if (Schema::hasTable('permissions')) {
foreach($this->getPermissions() as $permission) {
$gate->define($permission->name, function($user) use ($permission){
return $user->hasRole($permission->roles);
});
}
}
}
protected function getPermissions()
{
return Permission::with('roles')->get();
}
I still have to comment out the call in order to run composer dump-autoload
from outside of the vm. It seems like there is an issue with the setup that I am using for role-based permissions. I followed a tutorial that used an older version of laravel and it seemed to work until I ran into these issues.