Reputation: 19463
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:
I have modified the public/index.php file to be:
<?php
use Illuminate\Http\Request;
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
Symfony\Component\Process\Exception\RuntimeException
The provided cwd "C:\wamp64\www\my-project\program\public" does not exist.
What are the things needed to modify to get it works?
Upvotes: 0
Views: 1758
Reputation: 71
Update Bootstrap/app.php
------------ replace top 4 lines with old script. ----------------
return Application::configure(basePath: dirname(__DIR__))
->registered(function ($app) {
$app->usePublicPath(path: realpath(base_path('/../yourpath')));
})
->withRouting(
web: __DIR__.'/../routes/web.php',
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
//
})
->withExceptions(function (Exceptions $exceptions) {
//
})->create();
Upvotes: 0
Reputation: 18250
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:
$status = (require_once __DIR__.'/bootstrap/app.php')
->handleCommand(new ArgvInput);
to:
$status = (require_once __DIR__.'/bootstrap/app.php')
->usePublicPath('/your/public/folder')
->handleCommand(new ArgvInput);
Upvotes: 5