I have been encountering a weird problem with Laravel over the last week.
Basically, lets say for example that I am editing a view, "view.blade.php", and the controller, "ViewController.php", and I am constantly refreshing the browser page to see my changes.
My view is loaded by the index() function of my ViewController like so:
public function index()
{
return view('view');
}
Everything is working and I am seeing my changes reflected in the browser. However, all of a sudden for some reason, the page goes white and my view stops loading. No error in Laravel.log or console, nothing. It just shows a white page.
The thing is, if I change the name of my view file to "view2.blade.php" and change my index function to return 'view2' instead, the page loads as normal and works perfectly. It seems that the file name is the only thing keeping the page from loading.
I have tried clearing all the caches with the following artisan commands:
php artisan route:cache
php artisan cache:clear
php artisan view:clear
php artisan config:cache
and executing php artisan optimize
However, the problem still persists. I have not modified or added any vendor files.
This doesn't happen too often but it is annoying and it normally "magically" solves itself when I leave it alone for a while to work on another view/controller. However, I just want to know if anyone else has this problem and if there is a solution anywhere.
I defined my route like so:
Route::resource('view', 'ViewController');
Using Laravel 5.4
try to clear browser cash ctrl + F5
Hey try this url http://yoursite.dev/view/, do note you need to replace the yoursite.dev with your local domain.
By including the 'view' string in the resource function you are making a restful resource relative to the /view base domain.
Here is a link to the docs https://laravel.com/docs/5.4/controllers#resource-controllers
reference the table Actions Handled By Resource Controller for a thorough explanation.
Related
I'm trying to develope a program with Laravel, I have a problem with a Route, it shows me that is not define but it's already defined, also, I'm using Ajax.
This is the Error
This is my Ajax with URL and Route
And I tried to put the Route in that part of the code, but when I put there I get other problem.
I have tried this
Thank so much for your help.
After adding new route you need to clear cache. So run this commands:
php artisan cache:clear
php artisan route:cache
And check again
You have same controller method two time define and you did changed only route name? so it can return error. remove first route then it will work fine.
Route::post('schedule/destory', 'Client\SchedulesController#destory')->name('client.schedules.destory');
Route::post('schedule/destory', 'Client\SchedulesController#destory')->name('orders.schedules.store');
please remove Route::post('schedule/destory', 'Client\SchedulesController#destory')->name('client.schedules.destory'); route.
Route::get('/admin', 'Backend\HomeController#index')->name('admin.home');
is from routes/web.php and it's not working online. It's fine in local
Route::get('/superadmin', 'Backend\HomeController#index')->name('admin.home');
or any name except 'admin' is working online and local.
But I've already used /admin in my project in many places.
That's why I can't use /superadmin.
Please Help.
website backend:
http://ischebazar.com/admin
login:
http://ischebazar.com/admin/login is working.
I can't comment so I need to post an answer for this.
What do you mean by it does not work? Does it show you the laravel 404 page, a server error or a blank page?
If it shows you the laravel 404 page try clearing the route cache: php artisan route:clear.
If it's a blank page, try checking if you have a folder called admin in the document root of the project.
For a server error I can't guess whats wrong but you can provide additional information if this is the case.
Try executing the following command to clear out cache,
php artisan config:cache
I installed Laravel (in W10/Wamp3.3/PHP5.6) using Composer and created a new project with the following command:
laravel new my_project
Project doesn't have a welcome page, opens file-list directly. So I decided to try my chance on creating a new controller and create a route.
php artisan make:controller Hello
And my route in routes/web
Route::get('/hello', 'HelloController#index');
I also cleared the route cache:
php artisan route:clear
Created the controller with no methods. myproject/hello shows nothing.
What am I missing? File permissions or wamp based problem?
There's a question related with this but it's more like a server problem.
Few causes for this that I've run into. Most likely one is going to be the server pointing to the incorrect directory. What I would do to test is run php artisan serve from the root of the project. This will open up a server pointing to public directory. If this functions correctly then you have confirmation.
I'm facing a problem in Laravel. It seems that sometimes the Laravel framework loads an old version of a controller.
I created a new function and sometimes Laravel found it and sometimes it returns that the method does not exist.
What could be the problem in this case?
This is my function:
public function test(){
echo 'Here'; exit();
return view('welcome');
}
The Page sometimes show only Here (which is correct) and sometimes it redirects me to the welcome blade without showing the Here message.
Please make sure you are define the url in web.php within route folder
or use this command
php artisan cache:clear
php artisan config:cache
I've encountered a problem while creating simple apps with Laravel on IIS.
When I create a new Laravel application I can see the Laravel welcome page just fine.
If I create another view in the same folder as the welcome.blade.php (test.blade.php for example), and set up the route for that in routes/web.php I can't navigate to that page in browser. EDIT: When I attempt this I get a 404.
My web.php is as follows:
<?php
Route::get('/', function (){
return view('welcome');
});
Route::get('/test', function (){
return view('test');
});
At first I thought that perhaps the project was not reading web.php, but when I run php artisan route:list the test route is listed.
I thought perhaps that my view didn't work, so I renamed it as welcome.blade.php and that loaded up fine. I just seem to be unable to add a route to any view or anonymous function that isn't mapped to welcome.blade.php
I tried adding a static route.php file into the app directory with the same code, but that made no difference to the result.
I'm sure I must be missing something basic, but I can't seem to put my finger on where I've gone wrong. Would massively appreciate any help you might be able to offer. Thank you.
Right I worked out where I went wrong. I hadn't run artisan serve. Very simple.
If you're having this problem, try navigating to your application root in cmd and then try
php artisan serve
Then navigate to your page using that information.
Thank you to everyone who posted, massively appreciated.
You need to install Url Rewrite in your terminal. Then import the .htaccess file located in your project/public folder.
To install Url Rewrite, you need to install Web Platform Installer (WPI). Once installed, open WPI then search for the keyword "Url Rewrite", then install the first item in the result. Once the download is finished, Url Rewrite will be available in your IIS Manager
I think IIS server maybe blocks test url.
IIS server has such features.
Before time, I remember that I used IIS blacklist url feature.
You may check IIS url block feature.