Laravel Boilerplate Accessing Frontend page from Backend - php

In Laravel boilerplate, how could we accessing frontend page while logged in at backend environment?
I've put this routes at frontend access.php, but while putting it at access.php in backend, it doesn't load properly
Route::get('test', 'LoginController#showTestForm')->name('test');
Project Structure

Default namespace in route.php file is related to Controller directory (if not specifically changed by application developer). Try this:
Route::get('test', 'Frontend\Auth\LoginController#showTestForm')->name('test');

Related

I cannot be an admin anymore?

I tried to make an authentication page with Laravel and I simply made it with php artisan make:auth
The code was generated into Controllers and as view, in /resources/views/auth. I moved the folder into another folder: /resources/views/admin/auth and now I get this error:
View [auth.login] not found.
For routes I used: Auth::routes(['register' => false]);
What can I do now?
It looks for a view under /views/auth/login, however you moved the files to /views/admin/auth - everything is under admin.
You have to move the views back up one directory, or customise the routes in the AuthController.

Laravel: Put index.php in a subfolder of public folder

I have singlepage app at https://example.com.
App's api and backend is driven by laravel.
Can someone point me to the right direction how to open my spa at: https://example.com and backend at https://example.com/backend
What I've tried:
I've put all my files of SPA in public folder and move laravel public files (including .htaccess and index.php) in public/backend folder
Changed the public path of laravel to public/backend
This gives me Internal Server Error when access https://example.com/backend
Thanks in advance!
In case you want your SPA served via Laravel
Edit your routing so the api group is changed to backend. Then create a route in the web group for / which loads a blade template containing your vue components and vue router. The vue router will handle the SPA page loads after its loaded.
In case you want your SPA served separately from Laravel
In this case you'll have an entry point for your backend which is index.php. And you'll have an entry point for your SPA which will be index.html.
I would advice you to keep your index.php in the /public folder of our Laravel installation. Then change the way index.html is compiled so it's placed in a different folder, lets say /build. You can probably achieve this by adjusting some webpack or vue-cli settings. Then adjust your webserver configuration (apache/nginx) so it will have the following two entries:
https://example.com/backend which maps to /var/www/{project}/public
https://example.com/ which maps to /var/www/{project}/build

Laravel 5.6.12 how to redirect to plain html angular 4 app after login

I want to use my laravel installation as a session and request handler without using blade view templates. I've added an auth controller to the app with:
php artisan make:auth
And login, register, forgot password etc. all work perfectly. What I wanna do though is to redirect the user to an angular 4 single page app that resides in a subfolder named dashboard-dist in laravel root which I build independently from the laravel project. In other words I don't want to use the V in MVC of laravel and have angular handle the views.
I want to use restful API calls to laravel controllers to do the rest of back-end business apart from login, register etc.. How can I redirect the user to index.html inside this folder and keep the session goodness at the same time and have restful request handlers work?
1) Compile your angular app
2) Change your angular index.html entry point to be index.blade.php and move it to the views folder, then fix all js and css files connections
3) Create a route to render that view
4) Use return redirect(route) to redirect to that route from wherever you need
5) ...
6) PROFIT!!!11
First I edited the config/view.php:
'paths' => [
resource_path('views'),
public_path('dashboard-dist'),
],
And then built the angular project to reflect that base href change:
ng build --base-href /dashboard-dist/
And voila... Angular 4 inside the laravel goodness.

CodeIgniter index.php 404

I am using CodeIgniter for both frontend and backend. My backend isn't really that complex so it didn't warrant a different installation of CI. What I have now is a sub directory in controllers cms where I have all my backend controllers including a backend Index which extends MY_Backend core. Now I'm working on getting my front end up and running and have come across a problem if I have an Index file in the main controllers directory that extends MY_Frontend core. And try to access it via localhost or localhost/index I get a 404 page. If I change the name and subsequently the class name to Homepage I can access it via localhost/homepage.
Is this possibly due to having an Index file in the cms sub-directory? Otherwise, what is the issue? Here is my directory structure:
As at the base of it all controllers extend CI_Controller, there are 3 naming restrictions in place for controllers:
CI_Controller
Index
Default
Using any of these would cause a problem in some shape or form. I'd suspect this would be why your controller works fine named as Homepage, but not as Index.
Source: https://www.codeigniter.com/user_guide/general/reserved_names.html

Laravel- view is not working

I am using Ubuntu 16.04 and installed Laravel 5.3 on desktop/Laravel/test directory. I have created a test.blade.php file in resources/view directory. I have also created routes.php in app/Http directory and added following code:
Route::get('/', function(){
return view('test');
});
When I enter command in terminal: php artisan serve and go to http://localhost:8000 url in browser, it shows default page of laravel after installation. Why it is not showing view I have created? I have also tried writing following code in routes.php:
Route::get('/', function(){
echo "Test";
})
But still it doesn't work. Is there anything I am missing?
Reference
By default, fresh Laravel 5.3 applications contain two HTTP route
files in a new top-level routes directory. The web and api route files
provide more explicit guidance in how to split the routes for your web
interface and your API.
The routes.php is moved to different folder in Laravel 5.3. Update routes/web.php file.
From the Laravel Documentation 5.3
The routes directory contains all of the route definitions for your application. By default, three route files are included with Laravel: web.php, api.php, and console.php.
The routes.php was there in previous version. But in laravel 5.3 the routes.php is moved to routes/web.php as Saumini Navaratnam said.

Categories