VPS Ubuntu php artisan commands not working - laravel

I can't run any php artisan command, it shows always the same error. I understand what it say but I can't execute php artisan migrate to make that table. I'm on VPS Ubuntu 16.04. Everything works perfectly on my localhost,this problem appears only when deploy app on vps
error image
error is:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cv.contacts' doesn't exist (SQL: select * from `contacts` where `contacts`.`deleted_at` is null)
My routes:
Route::get('/', 'HomeController#index')->name('home');
Route::post('/', 'ContactController#store')->name('contact.store');
//eng
Route::get('/en', 'HomeController#index_en')->name('home.en');
Route::post('/en', 'ContactController#store')->name('contact.store');

Related

How to fix the "Table doesn't exist" error error when running 'php artisan migrate' command?

I have a project on which I need to run php artisan migrate. It should be easy but I am getting an error:
php artisan migrate
Illuminate\Database\QueryException
SQLSTATE[42S02]: Base table or view not found: 1146 Table
'skz.master_courses' doesn't exist (SQL: select * from
master_courses where date_from > 2021-06-01 and
master_courses.deleted_at is null order by date_from asc limit
1)
I don't understand where the select command comes from. Does anybody know where is it from?
The error usually throw when database doesn't exist in mysql.
But in your case, database exists in mysql server.So you it look like your application executing select query in any one of the service provider boot() method
public function boot()
{
}
So you might need to stop query execution till migration completes.

Laravel project not run by php artisan serve command

error when run php artisan serve command
C:\xampp\htdocs\crm>php artisan serve
In Connection.php line 647:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'crm.clients' doesn't exist (SQL: select * from `clients` where exists (select * from `followups` where `clients`.`id` = `followups`.`client_id` and `followup` = TBRO and date(`date`) = 2018-02-18))
In Connection.php line 319:
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'crm.clients' doesn't exist
the trouble seem to be that you don't have the table created. Have you ran the migrate command?
In this case, you have to first update your composer by this command.
composer update
I can suggest you to check your db if there is a db called crm in the case you are in a MySQL environment and also check your connection to the database in the config/database or in the .env . It seems that you cannot create the table with the migrate command and since you doesn’t have the tables the serve command report an error.

PHP artisan migration error

When i m executing PHP artisan migrate I'm getting following error
C:\xampp\htdocs\Social>php artisan migrate help
[ErrorException]
include(C:\xampp\htdocs\Social\vendor\composer/../../app/Http/Controllers/A
uth/AuthController.php): failed to open stream: No such file or
directory
C:\xampp\htdocs\Social>php artisan migrate
[ErrorException]
include(C:\xampp\htdocs\Social\vendor\composer/../../app/Http/Controllers/A
uth/AuthController.php): failed to open stream: No such file or
directory
C:\xampp\htdocs\Soci
how to solve this problem please help???
It looks like you're trying to use Laravel auth system by adding Auth::routes(); (Laravel 5.3+) or Route::auth(); (Laravel 5.2) to the routes file, but you didn't create controllers and views. So, you'll need to remove the line from the web.php and run this command:
php artisan make:auth
After that put Auth::routes(); back to the web.php. Or Route::auth(); to the routes.php if you're using Laravel 5.2 and lower.
https://laravel.com/docs/5.4/authentication#authentication-quickstart
Run composer install in your root project folder (or php composer.phar install)

Base table or view not found: 1146 Table 'db.ken_permissions' doesn't exist

Sometimes, when I type :
php artisan
php artisan migrate
etc
I get the message:
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'db.ken_permissions' doesn't exist (SQL: select * from `ken_permissions`)
Debugging, I can tell my problem happens in the artisan file in:
$status = $kernel->handle(
$input = new Symfony\Component\Console\Input\ArgvInput,
new Symfony\Component\Console\Output\ConsoleOutput
);
I had already check this answer, and didn't work:
bootstrap/app.php is clean,
I don't have app/start folder ( L5.1),
routes.php is clean
php artisan -v or php artisan --pretend doesn't work, because artisan fails before running it seems.
The only thing I have is in app/Providers
public function boot(GateContract $gate)
{
parent::registerPolicies($gate);
// Dynamically register permissions with Laravel's Gate.
foreach ($this->getPermissions() as $permission) {
$gate->define($permission->name, function ($user) use ($permission) {
return $user->hasPermission($permission);
});
}
}
One solution is to delete all my tables, then composer dump-autoload, and then it work again, but it constantly comes back.
Is it a way to trace what migration is failing?
Any idea why is it happening?
Tx!
Go to the App\Provider\AuthServiceProvider
if you use on boot method GateContract ($this->getPermission() etc), remove or add to comment all after parent::registerPolicies($gate); and done run php artisan migrate
Adding to watcher's answer here
Remove any lines requesting data from your model from these files to be sure artisan is not trying to load data from your non-existent table:
bootstrap/start.php
app/start/global.php
app/start/local.php
app/routes.php
Also be sure to un-register any service providers that utilize data from that table in their register or boot methods inside of app/config/app.php.
You can move your migrations to a database/temp folder and run your migrations one by one
php artisan migrate --path=database/temp
you will know which migration is causing problem.
NOTE
Also you can use
php artisan migrate --pretend to get the query you are trying to do.

Laravel: Base table or view not found: 1146 La Table 'database.migrations'

I was creating an application on Laravel. At some point of time, I had to reinstall my WAMP server. Now I installed it again and created the same database. When I tried to migrate everything again using the command php artisan migrate, I got the following errors.
[Illuminate\Database\QueryException]
SQLSTATE[42S02]: Base table or view not found: 1146 La table 'learning.migrations' n'exists pas (SQL: create table 'migrations' ('migration' varchar(255) not null, 'batch' int null) default character set utf8 collate utf8_unicode_ci)
and
[PDOException]
SQLSTATE[42S02]: Base table or view not found:1146 La table 'learning.migrations' n'existe pas
and
migrate [--bench[="..."]] [--database[="..."]] [--force] [--path["..."]] [--package[="..."]] [--pretend] [--seed]
What might be the problem? How can I solve this?
You can try this:
In your phpMyAdmin: create the database.
In your command console:
1) In your proyect folder execute: php artisan migrate:install
This will create the table "migrations" in your database
2) Then execute: php artisan migrate
The problem was from the wamp reinstall. When I reinstalled the wamp server, in the MySQL folder, there was an old file with the database name and everything (this was because I had not deleted the DB before reinstalling WAMP). So all you gotta do is go to your MySQL installation folder, in my case: C:\wamp\bin\mysql\mysql5.6.17\data and delete the folder with the old db name. This should solve your problem.

Resources