Laravel ReflectionException in Container.php class not found - php

Recently,I just installed a chat package called Easychat. At first, it worked perfectly. I don't why but today I'm facing a problem where It said as in the pic
In the console it also said: Failed to load resource: the server responded with a status of 500 (Internal Server Error)
The weirdest thing is that when I go to Route file and change the URI from easychat to something different like easychat222 just for testing.
From
Route::get('/easychat', [
'as' => 'chatnow',
'uses' => 'EasychatController#getIndex'
]);
To
Route::get('/easychat222', [
'as' => 'chatnow',
'uses' => 'EasychatController#getIndex'
]);
and refresh the page. It works perfectly with the old uri (easychat) not with the new one.
Anybody knows what is the problem here and please tell me how to fix it.
Thank you very much!

You're using wrong web server configuration. You should point web server to a public directory inside Laravel directory and restart it.
Change these lines in Apache config file (if you're using Apache):
For Apache you can use these directives:
DocumentRoot "/path_to_aravel_project/public"
<Directory "/path_to_aravel_project/public">
For nginx:
root /path_to_aravel_project/public;

Related

Laravel BoilerPlate : Defining Route

I have used Laravel Boilerplate for development of my application. Beside that I have installed L5Modular with it. So i define the route Like following inside my Modules
<?php
Route::group(array('module' => 'test', 'middleware' => ['web','auth'], 'prefix'=>'frontend','namespace' => 'App\Modules\test\Controllers'), function() {
Route::resource('test', 'TestController');
});
But when i tried to access the route http://localhost/blog/public/test/create it's showing 404 Error.
Why my route not accessed? is there any error of defining route?
You need to configure a virtual host to get laravel working, that's quite easy and even easier if you're using any software such as MAMP or XAMPP.
If you're on a MAC I'd suggest to have a look at laravel valet: you'll have your web server running in seconds.
If you don't want to do any of this, you'll have to change a few things in order to get Laravel working in a sub directory.
You might forget to write frontend prefix to URL. Try to access by:
http://localhost/blog/public/frontend/test/create

Laravel: routing not working

I have downloaded clients project from the internet, and it is programmed in Laravel (also seen by directory structure). I have set up homestead.yaml, hosts, filled the DB and modified .env. I also did a vagrant provision and 'composer dump-autoload` once everything was done.
Problem I'm facing is that home route '/' returns index.html in root. But route.php says different:
Route::get('/', 'PagesController#home');
Route::get('about', 'PagesController#about');
I've tried to intentionally modify routes so that they point to controller which doesn't exist, deleting some letters inside Kernel.php...anything that would reasonably produce an error, and nothing happens. I still get back what is inside index.html. Also there is index.php which gets returned after I enter anything after slash inside the url:
/bla
/nlo
/xyz
You get the point...what can be the issue?
I have also tried with artisan cache:clear
It's a webserver misconfiguration error. The webserver is configured to serve index.html with more priority than index.php. Relevant configuration can be found at /etc/apache2/httpd.conf, /etc/apache2/sites-available/your-site, .htaccess, or for nginx /etc/nginx/sites-available/your-site just to mention the two most common web servers.

Error with routes in Laravel 5.0

I have a problem when I use routes in Laravel 5.0, I only need to call this route:
Route::get('home', 'HomeController#index');
But the browser shows me this, when I write http://localhost/course/public/home:
Not Found
The requested URL /course/public/home was not found on this server.
Apache/2.4.9 (Win64) PHP/5.5.12 Server at localhost Port 80
If I write http://localhost/course/public/
the index works but the other routes doesn't work, I don't know why.
In my Routes.php I have this:
Route::get('/', 'WelcomeController#index');
Route::get('home', 'HomeController#index');
Route::controllers([
'auth' => 'Auth\AuthController',
'password' => 'Auth\PasswordController',
]);
I only downloaded laravel 5.0 with composer, I did not change nothing in the code after the download, I only want to test the routes and these don't work.
Thaks for your help.
in conclusion (the comments solved the problem, so thank you guys for this!!) you probably run Laravel on Apache and you don't have mod_rewrite enabled... or not configured correctly.
Laravel works with so called pretty urls. In order to achieve this, every request is rewritten and the config you can find in the .htaccess file in the public folder. This to give a quick and dirty explanation will let you write URLs without the index.php.
Additionally your server should serve the public folder and not the main folder. That's a security thing if you want to use your site in production.
Alternatively you can use nginx which in my opinion is a lot easier to configure and if you run laravel homestead everything comes straight out of the box.

Laravel routing on XAMPP with virtual hosts

I'm learning laravel, and have been following this phpacademy tutorial: http://www.youtube.com/watch?v=gf6yNkYVCjs I have virtual hosts setup with XAMPP Apache and that's all good.
In the routes.php file we have this:
Route::get('/', array('as' => 'home', 'uses' => 'HomeController#getIndex'));
Route::get('/login', array('as' => 'login', 'uses' => 'AuthController#getLogin'));
Route::post('/login', array('uses' => 'AuthController#postLogin'));
I type into my browser "tutorial" and I get the homepage as per the tutorial.
The problem is when I append login as in "tutorial/login" then I get a 404 error, object not found.
The AuthController etc is all in place, but I suspect that I have a routing problem, I just can't figure out where.
Update:
If I just use the php inbuilt server "php artisan serve" then it all works fine. So It looks like more of an Apache config problem than a laravel problem.

URL not found error in laravel4

I added this to my routes
Route::get('account/create',array(
'as' => 'account-create',
'uses' => 'AccountController#createGet'
));
then when i go to public/account/create , i got a
The requested URL /webproj/public/account/create was not found on this server error.
Then when I tried it to my /webproj/server.php it works.
You have some problems:
1) If you still need to use /public in your URL, the correct form would is:
http://server/project/public/index.php/account/create
2) You should not be using /public, so you need correctly configure your webserver virtual hosts, to point directly to /public so you can just access your urls as
http://server/project/account/create
3) /webproj/server.php should not be accessible and should not be used, Laravel needs it only for running
php artisan serve

Categories