Laravel Tinker error with SQLite database - laravel

Starting from a fresh project:
laravel new new-project
cd new-project
touch storage/database/database.sqlite
Then at .env
DB_CONNECTION=sqlite
DB_DATABASE=storage/database/database.sqlite
DB_FOREIGN_KEYS=true
The migration succeed...
php artisan migrate
php artisan tinker
>>>App\User::all()
But when I try to get all users it returns the following error:
PHP Fatal error: Class 'App/User' not found in Psy Shell code on line 1
What I could be missing?

Recently I reinstalled Laravel...
And I didn't realized I was using version Laravel 8
the models are at /app/Models
So the right command would be:
>>>App\Models\User::all()

i think it has something to do with the namespace alias. Try without the App/
Users::all();

Related

Adding column using make migration command error

I'm trying to add an icon_path column to an existing table called tbl_device
by using php artisan make:migration add_icon_path_to_tbl_device_table --table=tbl_device
and after running php artisan migrate, it gives me this error.
PHP Fatal error: Cannot declare class CreateFailedJobsTable, because the name is already in use in ...path\database\migrations\<date>_create_failed_jobs_table.php
Cannot declare class CreateFailedJobsTable, because the name is already in use
I've also tried manually adding the icon_path column to the create_tbl_device_table.php migration and after running php artisan migrate it says Nothing to migrate.
I think I followed all the instructions.. any idea where I went wrong?
Call artisan migrate command only for your specific migration using:
php artisan migrate --path=/database/migrations/my_migrations
And see if it works.

no php artisan commands are working after new migration

I am new to laravel .
Following tutorial videos on laracast,i made a new migration (cmd command) like following
php artisan make:migration delete_title_from_posts_table
which gave me the message
Created Migration: 2020_02_05_185721_delete_title_from_posts_table
after that no php artisian command is working in cmd.
Any command i run gives me the following error
In Container.php line 805:
Target class [db] does not exist.
In Container.php line 803:
Class db does not exist
what would be causing this?
my laravel app version=6.2 and php version=7.3.5 on Win10 64-bit.
similar questions i already viewed,not working for me
artisan-commands-not-working-after-composer-update
in-container-php-line-805-target-class-db-does-not-exist
Since it's a facade, add this to the top of the class to make it work:
use DB;
Or use full namespace:
$tables = \DB::table...
run these commands steps by step:
composer dump-autoload clean up all compiled files and their paths
composer update --no-scripts Skips execution of scripts defined in composer.json
composer update update your project's dependencies

using laravel 5.5 and get error to create my controller?

I am using laravel 5.5 and I get an error when I create my controller.
$ php artisan make:controller MyDatatablesController
I want to create new controller but I get this error:
[Symfony\Component\Debug\Exception\FatalThrowableError]
Parse error: syntax error, unexpected '=>' (T_DOUBLE_ARROW)
Your command is perfect their is some error in your project check your recent changes in your project
You're having an error on your own code. Probably it's a code not always executed. Try executing the command in verbose mode to have more information about the error
php artisan make:controller MyDatatablesController -vvv

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)

laravel PackageServiceProvider not found; moving from workbench to vendor

This is basically a problem of moving a laravel package from workbench to vendor, but the solutions in other threads have not worked in this case:
I have a package iateadonut/signup.
I created a fresh laravel installation (laravel_test), and, just for testing sake, I put iateadonut/signup in laravel_test/workbench/.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
Generating optimized class loader
Running for workbench [iateadonut/signup]...
My package is successfully installed.
On a fresh installation of laravel (laravel_test), I then put iateadonut/signup in larael_test/vendor.
I put Iateadonut\Signup\SignupServiceProvider, in the 'providers' array in app.php.
I then run:
/laravel_test> php artisan dump-autoload
and get:
PHP Fatal error: Class 'Iateadonut\Signup\SignupServiceProvider' not found in /var/www/html/laravel_test/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Iateadonut\Signup\SignupServiceProvider' not found","file":"/var/www/html/laravel_test/bootstrap/compiled.php","line":4214}}
Any idea what could be wrong?
Here is a more google friendly version in case someone else is looking for this:
PHP Fatal error: Class 'Vendor\Package\PackageServiceProvider' not found in /var/www/html/laravel/bootstrap/compiled.php on line 4214
{"error":{"type":"Symfony\Component\Debug\Exception\FatalErrorException","message":"Class 'Vender\Package\PackageServiceProvider' not found","file":"/var/www/html/laravel/bootstrap/compiled.php","line":4214}}
Try to remove the the bootstrap/compiled.php file and try your composer dumpautoload again

Resources