Call to undefined method error in Laravel 4.1 - php

My application was ok until I changed migrations and update composer. Now it returns an error like this:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to undefined method Package::with()
The Package model was ok before update process. I updated the system yesterday and now almost every modal returns error like above. What happened and what is wrong with new composer?

Are you using a dev version in your composer.json file? Did you list all the facades correctly in the app.php files in all your environments? Did you try a fresh composer dump-autoload? Did you try a new composer update to see if the bug has been fixed by now?

Ok I found the problem. Somehow php artisan migration:make command has created migrations with the same name of modals. I changed the class names of migrations and it works now.

Related

Yii2 Migration error - Unknown command: migrate\create Did you mean "migrate/create"?

I am learning database migration in Yii2. I am trying to create a new migration class create_news_table using command through composer.
I installed composer globally and running command
yii migrate/create create_news_table
I copied this command from yii2 official site Yii2 Db Migration
But after running command i got this error
Unknown command: migrate\create Did you mean "migrate/create"?
However i have written "migrate/create" not "migrate\create". Then why it is showing this error?
Please try this:
php yii migrate/create create_news_table
I was writing correct syntax. But the problem was with my composer.
I updated composer using composer update command and now it is working.
You have to escape / (slash). Try this:
yii migrate\/create create_news_table

Database Transactions Not Found - Lumen

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

Fatal error: Class 'Illuminate\Foundation\Application' not found

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

PHP Fatal error: Class 'Bllim\Datatables\DatatablesServiceProvider'

I'm a newbie in Laravel. I just cloned my co-worker git and try to php artisan list but it gives me error
PHP Fatal error: Class 'Bllim\Datatables\DatatablesServiceProvider' not found in /Users/path-to-project/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php on line 157
I can't find any documentations about this error and search results don't really help.
Any of you ever met this problem and care to help me fix this? Thank you.
Asking your coworker would be a first good step :)
That said, the error you're getting indicates that PHP can't find or autoload a Laravel Service provider class. If your coworker is following Laravel best practices, you should be able to fix this by running the following command from your root project directory (or the directory with a composer.json file)
$ composer install
or ...
$ composer.phhar install
The format of the command (phar or no phar) will depend on how you've installed composer, the dependency/package manager used in Laravel.

PHPUnit with Symfony Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle' not found

I'm trying to testing my app made with Symfony. I wrote a test and when I launch it, i get the following error:
Fatal error: Class 'Doctrine\Bundle\DoctrineBundle\DoctrineBundle'
not found in /.../app/AppKernel.php on line 17
I had the same error with Symfony's MonologBundle, AsseticBundle and SwiftmailerBundle: then I've manually added these bundles into my app, so pheraps I have fixed those errors, but with Doctrine I've not found any solutions yet.
It looks like maybe you did not install the Doctrine bundle.
Try to go to the root of your project where the composer.phar is located through a console, and try to run it like this:
php composer.phar
It will install all dependencies of Symfony2,and hopefully everything is going to work :)

Categories