sorry for my english.
I’m trying to create a laravel route but i just can’t make it work.
My project name is "portalRAG". It’s a web app. When i access "my.address/PortalRAG"
it works just fine, but i can’t make any other route work.
This is a new Laravel Project. It’s almost empty and i haven’t touched any major configuration other than creating some 1 or 2 views,controllers and model and only created some html code.
Here’s my web.php file:
<?php
use IlluminateSupportFacadesRoute;
use AppHttpControllers;
use AppHttpControllersragControllerragHomeController;
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::get('/', function () {
return view('login');
});
/* NOT WORKING
Route::get('test', function () {
return view('login');
});
*/
Route::get('test','AppHttpControllersragControllerragHomeController')->name('test');
I simply want to access "test" route. The controller i’m trying to use it’s called ragHomeController and it’s inside a ragController (a folder inside the basic Controller file).
Here’s ragHomeController.
<?php
namespace AppHttpControllersragController;
use AppHttpControllersController;
use AppModelsragModelragHomeModel;
use IlluminateHttpRequest;
class ragHomeController extends Controller
{
/**
* Display a listing of the resource.
*
* @return IlluminateHttpResponse
*/
public function index()
{
echo("WHATEVER");
}
/**
* Show the form for creating a new resource.
*
* @return IlluminateHttpResponse
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param IlluminateHttpRequest $request
* @return IlluminateHttpResponse
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param AppModelsragModelragHomeModel $ragHomeModel
* @return IlluminateHttpResponse
*/
public function show(ragHomeModel $ragHomeModel)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param AppModelsragModelragHomeModel $ragHomeModel
* @return IlluminateHttpResponse
*/
public function edit(ragHomeModel $ragHomeModel)
{
//
}
/**
* Update the specified resource in storage.
*
* @param IlluminateHttpRequest $request
* @param AppModelsragModelragHomeModel $ragHomeModel
* @return IlluminateHttpResponse
*/
public function update(Request $request, ragHomeModel $ragHomeModel)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param AppModelsragModelragHomeModel $ragHomeModel
* @return IlluminateHttpResponse
*/
public function destroy(ragHomeModel $ragHomeModel)
{
//
}
public function __invoke()
{
}
}
What i’m getting wront? i have tried clearing cache, clearing route cache, and nothing works.
How should i access my "test" route? (I have tried every way and i still can’t make it work).
"my.address/PortalRAG/test"?
"my.address/test"?
2
Answers
please write you route like below
and import your controller in top of your web
Note:sometime it won’t work so you have to run
if you are using xampp to run your laravel project then you can access your route like below
you didn’t use the method that located in ragHomeController so write it in this way
now open your route like this:
my.address/PortalRAG/test