-
-
Save sherbrow/57f61144eb17e7fab18e66adbe9f8fad to your computer and use it in GitHub Desktop.
Lumen 5.4 subfolder install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_URL=/subfolder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* To ease the pain of overriding helpers like url() and route() | |
* Little hack with LumenUrlGenerator and composer | |
*/ | |
namespace Laravel\Lumen\Routing; | |
class UrlGenerator extends LumenUrlGenerator | |
{ | |
protected function getRootUrl($scheme, $root = null) | |
{ | |
if (is_null($this->cachedRoot)) { | |
$this->cachedRoot = $this->app->make('request')->root(); | |
$baseUrl = env('BASE_URL'); | |
if ($baseUrl && strpos($this->cachedRoot, $baseUrl) === FALSE) { | |
$this->cachedRoot .= $baseUrl; | |
} | |
} | |
return parent::getRootUrl($scheme, $root); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
$app->group(['namespace' => 'App\Controllers', 'prefix' => env('BASE_URL', '')], function ($app) { | |
require __DIR__.'/../routes/web.php'; | |
}); | |
// ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"autoload": { | |
"psr-4": { | |
"Laravel\\Lumen\\Routing\\": "app/Routing" | |
} | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
abstract class TestCase extends Laravel\Lumen\Testing\TestCase | |
{ | |
public function setUp() | |
{ | |
parent::setUp(); | |
$this->baseUrl = $this->baseUrl . env('BASE_URL', ''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Since I wasn't going to find an easy fix like laravel/lumen-framework#35