Laravel 4 model not found inside a namespace - php

"Class ModelName not found", "Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)" is showing while using ModelName::find(1) in the controller which have a namespace of Controllers\admin and model is without any namespace. on the top of file, i applied use ModelName;. after following many guides, i applied php composer dump-autoload and composer du.
still shows model not found. what is the reason and how to use ModelName using Eloquont ?

Related

Symfony make:entity add property failed?

I have a problem when I want to create an entity under symfony 5.1.9 (I have the same problem under sf 4.4). I recently created a new SF project and still have the same concerns. The error message is as follows: In Validator.php line 158:
Argument 2 passed to Symfony \ Bundle \ MakerBundle \ Validator :: validateDoctrineFieldName () must be an instance of Doctrine \ Common \ Persistence \ ManagerRegistry, instance of Doctrine \ Bundle \ DoctrineBundle \ Registry given, called in D: \ phpProject \ API-bills \ vendor \ sy
mfony \ maker-bundle \ src \ Maker \ MakeEntity.php on line 303.
Thanks for help
It seems like the latest version is having some troubles. The easy fix for now is to modify your composer.json file and "downgrade" the doctrine/doctrine-bundle, from version ^2.1 to 2.1.0. After making this change, run composer update and everything should work.
As Florian said, referer to the maker bundle issues to see the complete reference on this error.

Laravel 4.2 Class not found error

return Redirect::to('')
->with('message',SiteHelpers::alert('success','Password has been saved!'));
I am getting error in above line saying that
Symfony \ Component \ Debug \ Exception \ FatalErrorException
(E_UNKNOWN)
Class 'SiteHelpers' not found
I kept SiteHelper.php in this path /var/www/html/login_session/app/library
I added "app/library" in my composer.json and run composer install in my terminal

Laravel5 can't use package

I'm using L5(dev version) and trying to create package.
Doing `php artisan workbench za-web/Sidebar --resources
It's creating for me structure and service provider.
And then I'm trying to add service provider to app/config.php
'ZaWeb\Sidebar\SidebarServiceProvider'
I've got the error:
Symfony \ Component \ Debug \ Exception \ FatalErrorException (E_ERROR)
Class 'ZaWeb\Sidebar\SidebarServiceProvider' not found
Also was trying to do composer dump-autoload but it doesn't helped.
I've figured out whats wrong, theres no autoload seciton for workmench directory in bootstrap/autoload.php
I've add it and not everything ok.
if (is_dir($workbench = __DIR__.'/../workbench'))
{
Illuminate\Workbench\Starter::start($workbench);
}

Call to undefined method error in Laravel 4.1

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.

Can't Find Model after creating Folder for Controller

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Class 'Controllers\Admin\User' not found
<?php namespace Controllers\Admin;
class UserStoreController extends BaseController{
Location of my Controller is app>controllers>admin>UserStoreController.php
It would work well outside admin folder, but once it's in admin folder it would fail.
I also tried PSR-0 on composer.phar autoload & use app\models\user;
basically i'm just trying to use laravel's ORM but i cant because the controller is in the folder.
Any idea how i could go around this issue?
You need to update the autoloader
composer dump-autoload
As JeannotLapin said, update the composer autoloader or add the path to Laravels built-in autoloading: /app/start/global.php, method ClassLoader::addDirectories()

Categories