I have tried to search for tutorial to move the public folder, but from all the guide it seems like the code is different than version 11. The folder structure I want to move will be like:
- public (public folder is here)
- program (all the other files to be stored inside this folder)
I have modified the public/index.php file to be:
<?php
use IlluminateHttpRequest;
define('LARAVEL_START', microtime(true));
// Determine if the application is in maintenance mode...
if (file_exists($maintenance = __DIR__.'/../program/storage/framework/maintenance.php')) {
require $maintenance;
}
// Register the Composer autoloader...
require __DIR__.'/../program/vendor/autoload.php';
// Bootstrap Laravel and handle the request...
(require_once __DIR__.'/../program/bootstrap/app.php')
->handleRequest(Request::capture());
However, when I try to run php artisan serve
, I get the error
SymfonyComponentProcessExceptionRuntimeException
The provided cwd "C:wamp64wwwmy-projectprogrampublic" does not exist.
What are the things needed to modify to get it works?
2
Answers
You must take care of how you load your project. Laravel has its own functions for path handling.
If you want change the
public Path
used bypublic_path()
function as the default app entry. You should register a new path in theAppProvidersAppServiceProvider.php
class.After that, your HTTP entry file will be
C:wamp64wwwmy-projectprogrampublicindex.php
To make artisan use a custom public folder, you can edit the artisan script to call the
usePublicPath()
method on the application object.Change these lines:
to: