I am creating an application to be hosted on a server, and I used .htaccess however the first page that load which is usually the login screen(whose path is in my resources folder)has change to the public folder and I click anywhere else as everything is linking to the public folder, which is not right as its supposed to be in the resources folder... the app works fine, its just the routing that's giving me an issue so when i click anywhere else it says, 'the requested url can not be found on server'
I also tried putting the view folder into the public folder and routing there
my homepage is set to:
Route::get('/', function () {
return view('auth/login');
});
but this gets an error when moved to the public folder, the error reads,
InvalidArgumentException
View [auth.login] not found.
Clear your caches and restart your server:
composer dump-autoload;
//---Flush the application cache
php artisan cache:clear;
//---Remove the configuration cache file
php artisan config:cache;
php artisan config:clear;
//---Remove Routes Cache
php artisan route:clear;
Related
I have a laravel application that I made changes to the folder structure, I have been working with laragon and everything works fine but on my local environment and live server.
However, when i user php artisan serve, the generated url doesn't load assets in the public folder.
E.g
https://livewebsite.com // [live server] works.
https://myproject.local // [laragon] works.
http://localhost/myproject // [laragon /xampp] works
http://127.0.0.1:8000 // artisan [doesn't load assets, assets in the public directory returns 404
//e.g http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css would return 404
Changes I made,
|-core
|-public
|-.htaccess
|-index.php
I have moved all laravel core folders and files to the core folder,
moved the .htaccess and index.php to the root directory.
From my debugging so far, I understand that laravel built in server redirects requests to the public folder where the index.php file is located.
What changes can I make so that the request is not sent to the public folder,
i.e http://127.0.0.1:8000/public/assets/themes/cryptic/style/bgs.css should just be allowed to be without be redirected.
The entire thing works on various environments except when I'm using laravel built-in PHP server with the artisan command.
EDIT
Folder structure
|-project
|-core
|-app
|-bootstrap
|-config
|-database
|-lang
|-etc
|-public
|-assets
|-test-folder
|-img.png
|-.htacess
|-index.php
in this setup, laravel base_path() is project/core . This where all laravel core files and folders are stored.
Now I have folder test-folder with an image img.png . If i go to http://localhost/project/new-folder/img.png it will return the image but if i go http://127.0.0.1:8000/new-folder/img.png will return 404. If i use a live server and go http://livewebsite.com/new-folder/img.png , it loads.
I can't comment due to reputation, but what you're doing might be unsafe!
This way all your project files will be public, which can expose credentials and exposes Composer packages to the public as well. This means any PHP file in any Composer package can be executed, which can lead to remote code execution, which has happened before here and is described here.
im new in laravel so im just try to run laravel without php artisan and read much topics about run laravel without php artisan but the main problem is the main route (/) is working and run (home view) but other routes like (/about) in web file doesnt work. so how can i run other views via routes (web file)?? i tried many ways for run laravel without php artisan but im stuck in this part routes. without routes, laravel is completely useless. i moved index.php from public folder and .htaccess to the root folder for run laravel wihout php artisan like this:root folder laravel
and this my index.php so i changed it to run from root not public folder:
index.php file
and .htaccess:
.htacess file
and finally this is my web file which is my routes:
web.php
when i set routes about and try to go to that, the error 404 is shown up: error 404 /about route
so how can i set routes and actualy the main problem is how can i request and Recieve urls from root without php artisan. and another way that i tried is rename server.php to index .php and i could say none of this ways are working. it just show the root home page not working for other routs. thanks
I am trying to create a view to display data from the database but I discovered that my route file doesn't do anything anymore.
At the moment I am trying to get the test function working but when I go to /test it just says "Page not found". The other routes work. Even if I delete all of the contents and save the file, all the other routes work.
I have tried artisan route:clear, artisan cache:clear and so on but nothing works.
This is my route file.
Route::get('/test', function () {
return "ok";
});//this is not workig
Route::get( '/', function () {
return view( 'welcome' );
} );
Route::resource( 'submission', 'SubmissionController' );
When you execute php artisan route:cache, Laravel creates a cached routes file in the bootstrap/cache/routes.php directory. While this file exists all your other apps route files will be ignored.
Anytime you create new routes you will need to re-generate the routes cache by executing php artisan route:cache.
If you need to remove the route cache you can execute php artisan route:clear.
If the above fails to solve your problem, it could indicate a permissions problem. Make sure the bootstrap/cache directory has the correct permissions to be altered/deleted.
Failing that, you could manually delete the bootstrap/cache/routes.php file yourself.
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 have just deployed Laravel 5.4 using Composer on a shared hosting and I've run into several problems which I think are now fixed.
The first one was folder permissions which is now fixed so at least I see a welcome page.
I noticed that composer install never create a routes directory so I uploaded a local version and also it never creates a cache directory in the boostrap folder which I fixed also.
I have installed Laravel on a subdomain and I want everything to run through the subdomain as the root folder has a different application.
If i got to the subdomain, the welcome page opens as expected but as soon as I try to use a different route, I get this error:
NotFoundHttpException in RouteCollection.php line 145:
I have looked at what other people have done with subdomains but nothing works for me. I don't know if there are other files are missing during the install
This is what I have in the Routes.php
Route::group(['domain' => 'subdomain.example.com'], function () {
Route::get('/', function () {
return view('welcome');
});
Route::get('test', function () {
return view('welcome');
});
});
I assume every route needs to run in the subdomain route group or do I need to use this at all seeing as the install is in the subdomain directory and the vhost is pointing to the subdomain public folder
It turned out to be a problem with the PHP version the command line was using on Plesk.
Currently Plesk runs in 5.4 and Laravel needed 5.6. For some reason Composer ran successfully and it seemed to miss downloading some of the files.
I wiped everything from the subdomain and thanks to this http://blogs.reliablepenguin.com/2015/08/18/using-php-composer-phar-with-non-default-php-install i was able to run composer using php version 5.6
I didn't need any special route for subdomains as everything is in the subdomain and these routes worked as expected
Route::get('/', function () {
return view('welcome');
});
Route::get('test', function () {
return view('welcome');
});