ReflectionException Laravel 5.1 - php

I have developed an application with Laravel, version 5.1, using homestead to test.
When I place it on the production server, I get this error that I can't replicate on the local machine:
ReflectionException in Container.php line 736
Class MyMultiSelect does not exist
This class is a sleeping-owl Custom Form Item
http://sleeping-owl.github.io/en/Form_Elements/Custom_Form_Elements.html
I checked for:
namespace errors / conflicts
I even placed the class in the global namespace
tried to load the file containing the class in composer.json
Filename: MyMultiSelect.php
Class: MyMultiSelect
namespace: Global so to access it \MyMultiSelect
admin/bootstrap.php
FormItem::register('myMultiSelect', \MyMultiSelect::class);
Can anyone help me?

Run composer dump-autoload on your server. This will rebuild the autoloader cache, that stores paths to classes. If your paths are different locally and on the server, this could help.

Related

Uncaught Error: Class "Illumninate\Support\Collection" not found

I'm working on a php project and need to use the Collection namespace from Illuminate. I have Laravel installed on my computer. However, when I try and create a new collection with:
use Illuminate\Support\Collection;
$collection = new Collection();
It gives me the error that it cannot find the class Illuminate\Support\Collection. I tried moving my Laravel folder into the same directory as the project and that didn't work either. I also tried looking through my laravel folders and couldn't find the Illuminate files anywhere. Do I have to do a separate installation to get the Illuminate libraries? Any help is appreciated.

Laravel: Class not found Exception

In my Laravel project, if have a file app/lib/Formatter.php, with an class Formatter.
From a Controller i am importing this php file using use App\Lib\Formatter;
In my local development enviroment, I can access methods from the Formatter in my Controller. But when i deploy the laravel project to a share hosting, i can't access Formatter. Laravel returns this error message:
"Class 'App\Lib\Formatter' not found"
After it works localy, i don't have any idea, why it shouldn't work on shared hosting.
Linux is casesensitive. You should rename your folder from lib to Lib.
If your folder tree looks like App\lib\Formatter.php rename your library to App\Lib\Formatter.php.

ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58

I recently started learning symfony 2.8 and trying to set up my 1st page on local host. However after configuring my bundle based on this tutorial: https://www.youtube.com/watch?v=S9aQxvEAdcE&list=PLp9j56Yo8a6aWJhLyggonvP7b8vIcYn5Q&index=3
i get this error :
ServiceNotFoundException in CheckExceptionOnInvalidReferenceBehaviorPass.php line 58:
The service "doctrine.orm.layout_entity_manager" has a dependency on a non-existent service "doctrine.orm.quote_strategy.layout".
when trying to open my page with adress localhost/st/web/app_dev.php
The reason I am asking this is that couldnt find anything about this particular problem and have no idea what these services is about. If anyone have any clue what I am doing wrong or why this error occurs please share those with me. I am not adding any code because I am not quite sure which files could be the reason of this error. Thanks in advance
EDITED :
I am creating new symfony project using php storm located in C:\wamp64\www\st (enabled symfony plugin and command line tool)
then generating a bundle called MainBundle
I rename DefaultController.php in MainBundle/Controller to MainController.php and change class within it to MainController.
Then rename default folder in app/Resources/views to layout, as well as base.html.twig to layout.html.twig
Then filling a twig files with boostrap template
Then change MainController.php into this :
<?php
namespace MainBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
class MainController extends Controller
{
/**
* #Route ("/", name="home")
*/
public function indexAction()
{
return $this->render('MainBundle:Default:home.html.twig');
}
}
then in src/Resource/views/Default change index.html.twig into home.html.twig
src/MainBundle/Resources/config/routing.yml fill like this :
main:
resource: "#MainBundle/Controller/MainController.php"
prefix: /
type: annotation
Adding github project link https://github.com/marras1/st
Ok so I am not quite sure what did the magic, but i found this idea here: Symfony2 post-update-cmd gives "An error occurred when generating the bootstrap file"
to remove the /bin and /vendor folders of your project.Then make a composer install (or php composer.phar install if your didn't install composer). In addition i ran php composer.phar update doctrine/mongodb-odm doctrine/mongodb-odm-bundle and the whole system seems working just fine for now.

Laravel 5.1 "ReflectionException in Container.php line 737:..class does not exist"

I'm sure that the solution to this problem is staring me right in the face, but unfortunately I can't seem to figure it out. I'm trying to add a route to my laravel 5.1 installation, and I'm getting the below error...
ReflectionException in Container.php line 737:
Class App\Http\Controllers\Tools\DashBoardController does not exist
I first edited the routes file to include the below...
(file: app\Http\routes.php)
Route::get('dashboard', 'Tools\DashBoard#index');
Then I created the "Tools" folder and "DashBoardController.php" file, and have it setup to look somewhat like the below...
(file: app\Http\Controllers\Tools\DashBoardController.php)
namespace App\Http\Controllers\Tools\DashBoard;
//...etc...//
class DashBoardController extends Controller { /* ..etc.. */ }
Is this all I have to do? I read that you could run "composer dumpautoload" in the terminal but unfortunately that didn't help.
I'm on a localhost XAMPP install w/PHP7 on Win7, if that's useful. Any help is greatly appreciated!
Your namespace declaration should look like namespace App\Http\Controllers\Tools and should not contain the filename or name of your class. Then you need to change your route to point to the name of your class Route::get('dashboard', 'Tools\DashBoardController#index');.
The way autoloaders and namespaces work in PHP and specifically in Laravel is that the namespace must reflect the directory structure and the class name must match its filename.
If you will have multiple routes using controllers from the same namespace, you will probably benefit from implementing route group namespaces.

Laravel package development

I am trying to develop a Laravel package with a helper function, which returns a view. I have uploaded on GitHub already https://github.com/faisalahsan/laravel-breadcrums. When I install it through Packagist https://packagist.org/packages/faisalahsanse/laravel-breadcrums, it installs successfully, but when I register it in the provider array in my app.php as Faisalahsanse\Breadcrums\BreadcumsServiceProvider::class,. It gives the following error:
Class 'Faisalahsanse\Breadcrums\BreadcumsServiceProvider' not found
I don't know where I am getting wrong.
Any suggestions?
Your namespace is wrong https://github.com/faisalahsan/laravel-breadcrums/blob/master/src/BreadcumsServiceProvider.php#L2
It should be Faisalahsan\LaravelBreadcrums. As this namespace you are adding in the composer.json file in psr-4 autoload.
Also your provider to add will be Faisalahsan\Breadcrums\BreadcumsServiceProvider::class

Categories