Docker 18.09.2
Mysql 5.7
Laravel 5.7
PHP 7.125
I am new at Laravel and I have a problem When I use php artisan db:seed, this error appeared:
include(/var/www/laravel_app/vendor/composer/../../database/seeds/AdminsTableSeeder.php):
failed to open stream: No such file or directory
at /var/www/laravel_app/vendor/composer/ClassLoader.php:444
440| * Prevents access to $this/self from included files.
441| */
442| function includeFile($file)
443| {
> 444| include $file;
445| }
446|
I have no idea why does it happens.
There was no error when I used php artisan migrate.
I have already tried php artisan migrate --seed and php artisan migrate:refresh --seed.
Can anyone please help me?
You should try using composer dump-autoload.
From this answer in SO:
Basically, because Composer can't see the migration files you are
creating, you are having to run the dump-autoload command which won't
download anything new, but looks for all of the classes it needs to
include again. It just regenerates the list of all classes that need
to be included in the project (autoload_classmap.php), and this is why
your migration is working after you run that command.
Related
I've been trawling for almost two days to find an answer, but no solutions to similar problems have helped to solve mine, so time to ask my own question.
Using Laravel 5.7 on Windows 10. When I run a php artisan make:migration command, or make a model with a migration (make:model -m), it runs fine once; the migration is created. But after that I am unable to run any further php artisan commands. Every time I try I get:
In Container.php line 779:
Class view does not exist
I've since discovered that the same issue also arises when making a seeder. I have noticed that upon running the first command, the bootstrap\cache\services.php file is being removed. Using a backup to replace this file in the directory fixes the problem, allowing me to run php artisan commands again. But the moment I make a migration or a seeder, the file is removed and I encounter the same error.
I have tried a composer dump-autoload. If the services.php file is in the directory, it gets removed again and I am shown the error.
I have tried composer update and composer install (including after removing the vendor folder)
I have tried php artisan config:cache and php artisan config:clear
I have checked my .env file for spaces not contained within quotations.
I have checked that 'Illuminate\View\ViewServiceProvider::class,' is in my config\app.php file under 'providers'.
Everything seemed to be working fine a week or so ago. I hadn't been running any php artisan commands in the interim or really working directly with my application at all during that time so I am not sure what has caused this issue to arise.
make sure to run this command:
sudo chmod 777 -R bootstrap/cache
I wanted to remove a package from laravel. I did composer remove vendor/package
It was all good on my dev, but when I deploy on production something went wrong and I cannot do anything now.
when I run
php artisan package:discover
I'm geting
In ProviderRepository.php line 208:
Class 'Laracasts\Flash\FlashServiceProvider' not found
I'm guessing I it is something to do with some kind of cache or maby config
but I cannot run this command,
php artisan config:clear
because I'm getting the same error message as above.
PS. I'm using Laravel 5.6
You may need clear the autoloader files if they get jammed up as it is looking at those cached files when php artisan config:clear runs, thus creating the jam.
Remove the following files and they will rebuild:
/bootstrap/cache/packages.php
/bootstrap/cache/services.php
I fixed my problem deleting a config file like so:
$rm bootstrap/cache/config.php
This file is basically a cache for config, if you want to have this file built for you just run a following artisan command:
$php artisan config:cache
I'm trying to use Laravel 5.5. I updated my php 7.0 to php 7.1. Even, I update my laravel installer package. But, when I try to do:
laravel new myProject
I get this error:
You made a reference to a non-existent script #php -r
"file_exists('.env') || copy('.env.example', '.env');" You made a
reference to a non-existent script #php artisan key:generate
Illuminate\Foundation\ComposerScripts::postAutoloadDump You made a
reference to a non-existent script #php artisan package:discover
I am using laravel valet and if I go to the browser, when I try myProject.dev is not working. I see this error:
Whoops, looks like something went wrong.
I tried using:
php artisan key:generate
inside my project, but I got that:
[ErrorException]
file_get_contents(/Users/jorgeJimenez/Sites/laravel5-5/.env): failed
to ope n stream
: No such file or directory
I noticed, my laravel 5.4 projects are working. I copied a .env file and I put on my laravel 5.5 projects. After that, I run
php artisan key:generate
and the key was generated and my project in the browser works.
It's supposed, all that process is automatic, but I am not quite sure what is happening.
You can try update your composer:
composer self-update
I had the same problem. Then I found that there was no problem when i created the first project use laravel 5.5. so I clear composer's cache dir. It works well now.
This is because of your Laravel Installer or Composer version. I have faced the same problem and found following 2 different solutions:
Generally you can solve with by running composer global update command and then run composer update command from your project directory. This solution basically updates your installer and then your project.
If still, you have this issue, you need to run composer self-update command first and then run composer update command from your project directory. Here your composer will update and then your project.
Hope this answer will help you.
I have changed my application by using command
php artisan app:name [app_name].
Then, when I try to perform other actions using following artisan commands,
php artisan down
php artisan up
php artisan config:cache
I got the following error:
PHP Fatal error: Class 'App\Providers\AppServiceProvider' not found
How can I solve it?
It is working after Clearing bootstrap/cache directory.
This is how its worked out for me in the case of a fresh install.
First, I cleared the files in boostrap\cache.
Then, in config\app.php, I added the below line in the providers,
\Laravel\Telescope\TelescopeServiceProvider::class,
Then I ran the below commands
php artisan telescope:install
php artisan migrate
And it was working after this.
I don't know for what reason the telescope provider didn't work which was added by Laravel itself. i.e App\Providers\TelescopeServiceProvider::class.
By the way my laravel version was 7.12.0.
In my case, some extension of the VSCode, added a use Illuminate\Support\Facades\App; at the beginning of the file /config/app.php.
I solved it by removing the line from the file and running composer install.
You might have deleted the folder called providers
App/providers.
I had a question like yours then I solved it by copying app/providers directory from another Laravel project to my project thus it worked
I had the same issue, I solved it by,
migrate migration file - vendor>laravel>telescope>database>- manually.
check app.php file, if App\Providers\TelescopeServiceProvider::class, exist or not, have to exist
Run in command shell>
npm run dev
I've run artisan migrate:reset.
I've deleted some of my migration files because I didn't need these tables anymore.
I ran composer dump-autoload followed by artisan dump-autoload
I ran artisan migrate and I keep getting this error:
PHP Fatal error: Class 'Foo' not found in /vagrant/LaravelBackend/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php on line 297
I tried to:
Run again composer dump-autoload and artisan dump-autoload (also used artisan clear-compiled)
Remove the migration table and run artisan migrate:install
Remove the vendor and composer.lock file and run composer install
Search within my project with PHPStorm for class Foo. Didn't find anything.
I keep getting the same error. It's the first time I run this since I updated to 4.2 if that could be related. Anything else I should be looking for?
I had this problem too.
Must remember: class name must be in accordance with filename.
Simple file renaming helped me:)
For example: in file "2014_12_08_100923_create_items_tables.php" must be class with name "CreateItemsTables" with using CamelCase words.
I solved my problem by
Removing all migration
Running composer dump-autoload
Adding them back one by one and running php artisan migrate
Deleting those that caused Laravel to throw an error
Create new migrations to replace the deleted ones
I'm not sure why that worked but my guess is that I might have modified the class name of these problematic migrations in the past.
I also found that renaming the migration with its initial name (The one throwed with the fatal error) also works for some of them.
I ran into this aswell and the solution was different to all of the above. The reason it was failing was because the filename was still mentioned in the migrations table of the DB. Because there were no unique columns I couldn't remove it with PHPMyAdmin and had to tak the CLI route.
Login to your server as root.
Type the following:
mysql -p database_name
(it now prompts for your password. From here on out everything is preceded with mysql > which just means that you're in the Mysql environment.
select * from migrations;
Look for the migration file you removed and copy the name.
delete from migrations where migration = '2015_07_21_000119_create_some_table';
It should mention something about 1 row affected. Now verify that it's gone by typing the first command again:
select * from migrations;
If it's gone exit the Mysql environment by typing
exit;
Now try 'php artisan migrate:rollback' again and it should work like a charm :-)
The actual solution is to use the correct naming for your translations. You still may need to do a
composer dump-autoload
The migration files must be as follows
YYYY_MM_DD_000000_create_some_table.php
and the class name inside must be
class CreateSomeTable extends Migration{}
There is an easier way.
Recreate those delete migrations manually. artisan make:migration
run artisan migrate:reset to rollback
Delete those dummy migations files just created.
run artisan migrate:refresh
I know this is a bit past but there is a better way actually. Run the following in terminal and feel free yourself to remove any of them:
~$ php artisan clear-compiled;php artisan cache:clear;php artisan config:clear;php artisan debugbar:clear;php artisan view:clear;php artisan optimize
To do it a regular task create an executable file named artisan-clear:
#!/bin/bash
php artisan clear-compiled
php artisan cache:clear
php artisan config:clear
php artisan debugbar:clear
php artisan view:clear
php artisan optimize
For me, the solution was that my class name inside the migration somehow started with a lowercase letter. When I changed the class name to be all upper case, then ran a composer dump-autoload, it ended up working for me. This is using Laravel 5.1, for what it's worth.
I did like this:
1. Deleted row non exist migration from migrations table from database
2. And run the command php artisan migrate:refresh
This helped to solve my problem.
*all your data will deleted from database tables
version 5.1.3 same problem fix it me:
drop database all tables
php artisan migrate:status
output: No migrations found.
ok use it
php artisan migrate:install
php artisan migrate
output is:
Migrated: 2016_11_24_093015_dt_some_table
Migrated: 2016_12_05_141004_dt_some_table
Migrated: 2016_12_07_110518_dt_some_table
Migrated: 2016_12_08_141807_dt_some_table
Migrated: 2016_12_13_090832_dt_some_table
this problem is solved
I had the same problem. When I was hiting php artisan migrate:reset, I got Class 'CreateImagesTable' not found. And composer dump-autoload didn't help.
My solution was very easy:
php artisan make:migration create_images_table --create=images
composer dump-autoload
Then I got:
SQLSTATE[HY000]: General error: 1 no such table: images (SQL: drop table "images")
so in sqlite I typed:
CREATE TABLE `images` (
...> `id` INTEGER
...> );
And then php artisan migrate:reset
Now I'm happy again
If artisan doesn't work at all and keeps throwing you this message no matter the command you give, delete the config.php file from bootstrap/cache folder.
After that run again
php artisan config:cache