I've been writing tests in lumen but I need to move to a different machine so I've been trying to set it all up. I copied over my tests but I get this error on all of them when I run them
[Symfony\Component\Debug\Exception\FatalErrorException]
Trait 'Laravel\Lumen\Testing\DatabaseTransactions' not found
I think I have lumen installed as I did the command composer require "laravel/installer". Is there something I'm meant to do?
Edit:
I looked at the version that was working on my old machine and this code was at the top of app.php in the bootstrap folder
try {
(new Dotenv\Dotenv(__DIR__.'/../'))->load();
} catch (Dotenv\Exception\InvalidPathException $e) {
//
}
I inserted that at the top of app.php on my new machine and that error stopped appearing and I was now able to run a test. Unfortunately a new error occurs when I just have the default example test
1) ExampleTest::testBasicExample
Error: Call to undefined method ExampleTest::visit()
I'm guessing that I'm still missing something from lumen/laravel
That command is for the Laravel installer. The command for the Lumen installer is:
composer require "laravel/lumen-installer"
However, even then, that only installs the installer. You still need to run the command to create a new install (e.g. lumen new my-site).
There's a lot of ambiguity as to what you're trying to do and what you've attempted.
Generally when installing your site on a new machine, you should just need to clone your repository (or copy your code over), and do a composer install.
Try the following:
composer cache clean
composer update
composer dump-autoload
Related
I was developing on my dev machine using Homestead. I committed both my composer.lock and composer.json. During this branch, I added Hashid and LaravelDebugBar to composer for development purposes. Everything worked fine on the development machine.
Once I pulled from master to my production machine, and ran composer update, and I get the following error:
When I type in php artisan migrate or composer update, I get the following error:
PHP Fatal error: Class 'Vinkla\Hashids\HashidsServiceProvider' not found in /var/www/schedulizer/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 146
[Symfony\Component\Debug\Exception\FatalErrorException]
Class 'Vinkla\Hashids\HashidsServiceProvider' not found
I tried composer clear-compiled, composer dump-autoload tried manually requiring the Hashid package, and removing the offending lines in config/app.php and running composer update
I checked the service provider, and it is in my config/app.php..
Instead of running composer update, run composer install on the production machine instead; this will bypass the pre-update hooks that Laravel runs.
Source
If they were dev requirements, then you can conditionally add them to your service providers list by adding them to your AppServiceProvider like such:
// AppServiceProvider.php
public function register()
{
/* ... */
if ($this->app->environment('production')) {
// $this->app->register('');
} else {
$this->app->register('Vinkla\Hashids\HashidsServiceProvider');
}
}
Source
First of all, check if Vinkla\Hashids\HashidsServiceProvider exists. Also, double check all letter (it's always better to copy-paste namespace from documentation). Then try to run this command:
composer dumpauto
If it will not help, run this command:
composer dumpauto -o
I tried php artisan config:clear then I ran composer update and composer install but I got the same error message.
in my case, the problem was in bootstrap/cache/config.php
So I deleted the file manually and mission accomplished.
I'm been at this for days with no success. Running Laravel 5.1.
As I understand according to the Laravel doc.
An ExampleTest.php file is provided in the tests directory. After installing a new Laravel application, simply run phpunit on the command line to run your tests.
Ok so after running phpunit I found it is not globally installed and is located in vendor/bin/phpunit. Proceeding to run vendor/bin/phpunit gives me a screen with all the command options for phpunit. Its does not actually run any tests.
I searched more and came across a post that mentioned it could be a symlink issue. I followed the instructions in the post with no success. From memory I installed Laravel from composer so the symlink should not be an issue anyway.
These instructions involved deleting various files. I did notice that composer was pulling files from its cache when updating. So I cleared its cache and followed the process again. Still no success.
What are the tests not running? I'm at my wits end. Especially since its is supposed to run easily out the box.
In the end I was not calling the bat file correctly. I was running
C:\localhost\myProject\vendor\bin> phpunit
Instead I needed to run
C:\localhost\myproject> call vendor\bin\phpunit
Hence it now is referencing the phpunit.xml file with the test location information.
You need to install phpunit globally:
composer global require phpunit/phpunit
Then you can run phpunit from your project root.
You could just run the phpunit that comes with the project, just go to your project root and run ./vendor/bin/phpunit, that way the tests will execute the way they should be and you could get feedback in case it fails.
For some reason I haven't figure out yet if you install phpunit globally in your computer you won't get feedback of your tests.
I am getting following error when I open my site which is made using laravel 5
Fatal error: Class 'Illuminate\Foundation\Application' not found in C:\cms\bootstrap\app.php on line 14
I have tried removing vendor folder and composer.lock file and running composer install it's not working I tried running PHP artisan optimize but it shows error
Fatal error: Class'Illuminate\Foundation\Application' not found
Is there any way to solve this problem?
Edited:
This problem aroused as soon as I used the php artisan make:model Page command which did create the model but then the above error gets displayed when I access the site
Also If use the Laravel's Local Development Server no such problem arises only if I use wamp server
In my situation, I didn't have the full vendor dependencies in place (composer file was messed up during original install) - so running any artisan commands caused a failure.
I was able to use the --no-scripts flag to prevent artisan from executing before it was included. Once my dependencies were in place, everything worked as expected.
composer update --no-scripts
Just in case I trip over this error in 2 weeks again...
My case: Checkout an existing project via git and pull in all dependencies via composer. Came down to the same error listed within the title of this post.
Solution:
composer dump-autoload
composer install --no-scripts
make sure everything works now as expected (no errors!)
composer update
Something is clearly corrupt in your Laravel setup and it is very hard to track without more info about your environment. Usually these 2 commands help you resolve such issues
php artisan clear-compiled
composer dump-autoload
If nothing else helps then I recommend you to install fresh Laravel 5 app and copy your application logic over, it should take around 15 min or so.
Easy as this, that worked for my project
Delete /vendor folder
and execute composer install
then run project php artisan serve
In my case composer was not installed in that directory. So I run
composer install
then error resolved.
or you can try
composer update --no-scripts
cd bootstrap/cache/->rm -rf *.php
composer dump-autoload
I just fixed this problem (Different Case with same error),
The answer above I tried may not work because My case were different but produced the same error.
I think my vendor libraries were jumbled,
I get this error by:
1. Pull from remote git, master branch is codeigniter then I do composer update on master branch, I wanted to work on laravel branch then I checkout and do composer update so I get the error,
Fatal error: Class 'Illuminate\Foundation\Application' not found in
C:\cms\bootstrap\app.php on line 14
Solution:
I delete the project on local and do a clone again, after that I checkout to my laravel file work's branch and do composer update then it is fixed.
I had accidentally commented out:
require __DIR__.'/../bootstrap/autoload.php';
in
/public/index.php
When pasting in some debugging statements.
For latest laravel version also check your version because I was also
facing this error but after update latest php version, I got rid from
this error.
run composer require laravel/framework after composer install then php artisan key:generate its work for me in kali linux
I can't imagine that anyone else reading this is a stupid as I was but just in case...
I had accidentally removed "laravel/framework": "^5.6" from my composer.json when resolving merge conflicts.
please test below solution:
first open command prompt cmd ==> window+r and go to the location where laravel installed.
try composer require laravel/laravel
i was having same problem with this error.
It turn out my Kenel.php is having a wrong syntax when i try to comply with wrong php8 syntax
The line should be
protected $commands = [
//
];
instead of
protected array $commands = [
//
];
#kalhan-toress 's comment is what ACTUALLY WORKED FOR ME
remove /bootstrap/start.php,composer.lock, and the vendor and run composer install
In my case, the error was caused on initial deployment because I didn't have a .env file in that directory (because those don't belong on Github where the files were transferred from).
check your .env file i think you miss something. Maybe like this
if yes then need to add manually and composer update or install composer
Today, I pulled down the laravel/laravel repository from Github. I then ran php composer.phar install (as I normally would on my system, with a command window in the project directory). However, when I ran php composer.phar update, I received this error:
Everything installed just fine, and Laravel works as it should.
Any ideas what could be causing this issue?
Edit 1
artisan exists in the root of the project, but it throws an exception when I attempt to run php artisan optimize:
Side Note 1
If I try the alternative method (quicker) of installing Laravel (php composer.phar create-project laravel/laravel), I get the following:
Edit 2
Upon installation, I also get the same error, where it claims it cannot find artisan. Therefore, the installation does not fully complete. I believe that it is stopping when it wants to compile classes (or something to that effect), and then write bootstrap/compiled.php. That file doesn't exist.
Here's the snap from the install:
Edit 3
It seems that Composer is looking for artisan in the drive root (C:\). Why is it doing this? Even if I specify -d on the update, it throws the error. (I picked this up from a hunch - simply copied artisan to the root of the drive and it found it - albeit, it obviously did not run...)
Solution Found:
Composer makes calls to php artisan <command> (as per the instruction in composer.json > scripts), but it does not see what directory it is running from (perhaps because it is an external command?).
So, I solved my initial problem by using an absolute path to artisan in composer.json.
Everything is working now. I just wish I knew how to get Composer to know that it is running from C:\LocalServer\lab\laravel, and not just C:\.
As i can see, your artisan file is missing. Can you post the exact steps on how you install it ?
Also, please follow http://laravel.com/docs/installation and http://niallobrien.me/2013/03/installing-and-updating-laravel-4/
I had this problem today too. My laravel folder inside the vendor was deleted after composer update. I ran composer install again and problem resolved.
I set up a Silex-project local using a XAMPP on Mac. Everything works fine. Now I uploaded the files to my Amazon ec2 server and tried to run it. I always get the php errormessage:
"Fatal error: Class 'Silex\Application' not found in /opt/bitnami/apps/..."
I'm using Composer to handle the dependencies. The first lines of my file look like this:
<?php
require_once __DIR__.'/../vendor/autoload.php';
$app = new Silex\Application();
$app['debug'] = true;
Anyone has a clue how to solve that? Where could there be a problem?
Thanks a lot! Cheers
As suspected, you are using some sort of git-based deployment process.
Currently there is no tagged stable release of silex (EDIT: as of now, there is). As a result, composer will install it from source, resulting in the silex github repository being cloned into vendor/silex/silex. Since that folder is a git repo itself, those files cannot be added to your main repo. Which means that on your server the vendor/silex/silex directory simply will not exist.
If you really want to, you can apply the fix of running composer install with the --prefer-dist flag, which will force to install silex from a zip archive, allowing the directory to be added to your git repo.
But I would say that you should not be committing your vendors into version control. This is also covered by this entry in the composer FAQ:
Should I commit the dependencies in my vendor directory?
I suggest adding vendor to your .gitignore and running composer install as part of your CI and deployment process.