"Whoops, looks like something went wrong." Laravel 4.1 - php

Okay, so I've just gotten around to checking out Laravel 4.1, I've hit a problem and I don't understand why? The problem is that I get this message on the screen "Whoops, looks like something went wrong." but I haven't really done anything. I've created a view, a controller and added a route and this is what is in these files
VIEW
<h1>Author's home page</h1>
CONTROLLER
class AuthorsController extends BaseController {
public $restful = true;
public function getIndex () {
return View::make('authors.index'); //authors.index because it's in the authors folder within the views folder
}
}
and ROUTE
Route::get('authors', 'AuthorsController#getIndex');
So logic dictates that when I go to the authors URL it should load the getIndex function within the AurhorsController page and show the index.blade.php file which is in views > authors.
If so then I have no idea why this is not working! any help would be appreciated. Thanks in advance.
EDIT 1
This is the actual error
throw new NotFoundHttpException();
EDIT 2

You should remove public $restful = true; but it's not a problem for NotFoundHttpException
// Path: app/controllers/AuthorsController.php
class AuthorsController extends BaseController {
// public $restful = true;
public function getIndex () {
return View::make('authors.index');
}
}
According to your route given below:
Route::get('authors', 'AuthorsController#getIndex');
It should work if you make a GET request, make sure you made the request from browser's address bar and url was like yourdomain.dev/authors or http://localhost/yourapp/authors. Also you may run following command from command prompt/terminal (within your project directory):
composer dump-autoload

Looks like Laravel's trying to access the public folder and fails, because there's no file named authors in that folder, and also no route named public/authors. You'll want to go to http://localhost:8081/branch/authors instead, assuming that your installation resides in http://localhost:8081/branch.

Related

InvalidArgumentException View [back.admin] not found

I have checked the path, and I checked the route. Unfortunately, nothing helps. I'm getting an error here:
DashboardController.php
class DashboardController extends Controller
{
public function admin()
{
return view('back.admin');
}
}
Route
Route::get('/admin', [App\Http\Controllers\DashboardController::class, 'admin'])
->name('back.admin');
InvalidArgumentException
View [back.admin] not found.
http://localhost:8000/admin
We should put the view file in the following directory to make it work:
resources/views/back/admin.blade.php
Return view ('back.admin') in the admin function in the controller
There is no file named views / back / admin under the resources folder. Can you check the file path?

Laravel 7 Redirect Login Authorization

I'm currently using template for my view using jQuery, HTML, and CSS.
When I tried to use middleware to authenticate the user role before accessing routes ,I stumble upon this error.
Error:
View [authorization.login] not found.
Is it because I use a different name or custom login for my page? How can I change the link to my current login address?
Here are my routes
Route::get('/user-register-page', 'LoginUserController#registerUserPage')->middleware(['auth','auth.admin']);
Route::post('/register-user', 'Auth\RegisterController#create')->name('register');
And here's my controller
class LoginUserController extends Controller
{
public function registerUserPage(){
return view('user-register');
}
public function loginUserPage(){
return view('user-login');
}
// public function registerNewUser(Request $request){
// dd('test');
// }
// public function loginUser(){
// }
}
In your resources folder inside views you will find a folder called auth, in case it is not there, create a folder called auth and drag in your file user-login and rename it to login.

I am unable to access Laravel view

I have just created one of about view in view/about.blade.php, and I am accessing this from localhost/myproject/public/about, but it's not working.
However, localhost/myprojects/public/ is working fine; about view has been created on same parameters as welcome by default in Laravel.
Firstly the information is not sufficient to say anything.Please provide your route.Also its important how you are running your project ,is it via Xampp(or Lampp whatever is there) or "php artisan serve"
but looking from your working directory "localhost/myprojects/public" I guess its not by the command . Try localhost/myprojects/public/about.blade.php or run it by php artisan serve and try route localhost:8000/about
Have you added particular routing to web.php file?
Route::get('about', function () {
return view('about');
});
https://laravel.com/docs/5.7/routing
Which error are you getting?
404 - Not found
Route::get('/about', function () {
return view('about');
});
Check routes
php artisan route:list
Laravel is a MVC Framework, Which means You Have a Controller which procede some logic when some request come in and interact with the model if need, after that the controller return some view.
And because you whan to acccess your view file, you must past through controller, and that controller will render the view. Because the views folder is not in the \public dicretory as subdirectory you can't access to It with url like localhost/myproject/public/about even if you get access to it, you will not get HTML, you'll get some plain text with Blade tags. It's a must to return view in you controller by rendering it, somewhere in the background Laravel procede all Blade Tag and return HTML that correspond to that tags.
What I can suggest you Is to create some route in your route file like this
Route::get('/about', function(Request $request){
// Automatically Laravel will look this file in the view directory
return view('about');
});
Or you can go with the controller like procedure by creating some controller, go in your terminal and execute
php artisan make:controller AboutController
this will generate a file name AboutController.php in app\Http\Controllers diretory within witch you will found
namespace App\Http\Controllers;
class HomeController extends Controller
{
}
after that add
public function index()
{
return View::make('about');
}
Don't forget to include use the Illuminale\Supports\Facades\View on top of your file
And one more important thing which left is to configure the Route, for that go in routes directory in the web.php file add
Route::get('/about', 'AboutController#index')->name('about');

how to invoke a specific controller action in laravel

I am very new to Laravel. I created new Controller as
class ContactController extends Controller {
public function index(){
die("X");
}
}
And in the routes.php I wrote
Route::get('contact', 'ContactController#index');
I think hitting the following url the "X" must be printed. But it says "Not Found" error.
http://localhost/lapp/public/contact/index
What thing I am missing? Please guide me.
If the apache module_rewrite is not activated. Activate it. It will surely work.
Your guess is right. But the problem is with you URL.
it should be http://localhost/lapp/public/contact
Alternatively you can use php artisan serve command to start a server which would start the server on something like http://localhost:8080 Then you can access the URL like: http://localhost:8080/contact

Cannot get FuelPHP action to run

I'm new to FuelPHP and I did a little coding with it! What I did was create a simple controller and created two methods. One for action_index() and the other is action_add().
the code is given below. Views are already in the app\views\ folder.
class Controller_Student extends Controller
{
public function action_index()
{
return Response::forge(View::forge('index'));
}
public function action_add()
{
return Response::forge(View::forge('select'));
}
}
I've set the root to this controller class. When I run the application the index works fine and loads the directed view. But when I give the following URL
http://localhost/project/public/add/
the method doesn't get called! A 404 error is give saying
You can see this page because the URL you are accessing cannot be found.
What Am I doing wrong here. I've gone through every documentation, tutorial I find but I shouldn't get this type of an error. Please help me.
Below is the routing file code :
return array(
'_root_' => 'student', // The default route
'_404_' => 'welcome/404', // The main 404 route
);
You've set the root to student controller, but that doesn't mean all traffic goes through that controller. Try visiting:
http://localhost/project/public/student/add/

Categories