Category : router

I am working on a project using PHP and routers. I have this error message. Notice: Undefined index: BASE_URI in C:laragonwwwmyprojectpublicindex.php on line 30 Notice: Undefined index: BASE_URI in C:laragonwwwmyprojectappControllersMainController.php on line 39 Here is line 39 : `$viewVars[‘baseURL’] = $_SERVER[‘BASE_URI’];` I also have a .htaccess file : RewriteEngine On # dynamically setup base URI ..

Read more

I am in the process of making a website with a router using the namesapaces for class. But an error occurs (see title). Here is the layout of my files: And here is my index.php (problematic file): <?php require ‘../vendor/autoload.php’; include_once "../src/PHP/functions.php"; $router = new AppRouterRouter(getURL()); $router->get(”, function () { include "home.php"; }); $router->get(‘/’, function ..

Read more

Why does my nikic/fast-route setup is not working as expected ? …I defined the route according to the usege on https://github.com/nikic/FastRoute but it does not seem to work. What am I doing wrong ? I need: admin ‘/public/admin/index.php’ to be at the root of my domain to be able to edit records using ‘/public/admin/edit.php’ and ..

Read more

I’m writing a router and I’m wondering how can I implement the route group section, I have routes like the code below that are in the callback function, How can I run them? Route::group(function () { Route::get(‘/admin’, ‘[email protected]’); Route::get(‘/admin/users’, ‘[email protected]’); Route::get(‘/admin/login’, ‘[email protected]’); Route::post(‘/admin/login’, ‘[email protected]_login’); Route::get(‘/admin/logout’, ‘[email protected]’); Route::get(‘/admin/profile’, ‘[email protected]’); Route::post(‘/admin/user/photo’, ‘[email protected]’); },[Gate::class]); Sourc..

Read more

I have app with Laravel and Vue I am using Vue Router and I want to fetch some data with axios. created() { axios.get(‘/api/events’) .then(response => { this.events = response.data }) axios.get(‘/api/organizers’) .then(response => { console.log(response.data) }) } And My Laravel api.php with web.php Route::get(‘/events’, function () { return Event::with(‘organizers’)->latest() ->get(); }); Route::get(‘/organizers’, function () ..

Read more

I would like to set up optional host parameter in Symfony router. I try it on localhost:8000 and if I call en.localhost:8000 it works but as I remove the first lang parameter it does not match the route. Route is defined in route.yaml file: blog-index: path: /blog/{page} host: "{lang}.localhost" controller: AppControllerBlogController::index defaults: lang: ‘en’ page: ..

Read more