Invalid URL being generated (with missing base URL) when trying to generate URLs in command
url('/customers');
route('customers.create');
// They end up generating
http://:/customers
// While they should generate something like
http://myapp.dev/customers
My route definition looks like below
$app->group(['prefix' => 'customers', 'namespace' => 'App\Services\Checkoutcom\Controllers'], function () use ($app) {
$app->post('/', ['uses' => 'CustomerController@create', 'as' => 'checkoutcom.create-customer']);
});
And yes, in my .env file, I do have APP_URL and routes are being correctly generated in the browser.
Sorry, I can't replicate this.
I ran into something similar yesterday while running PHPUnit. All of my URLs began with http://:/. Naturally, it does not look like Lumen uses APP_URL nor an app.url config variable. I downloaded Laravel today and looked around for app.url usage and see that there is a SetRequestForConsole class that seems to use app.url to set up the Request. Seems like that might be missing in Lumen?
+1. getting 'http://:/' anytime i access url() from phpunit/artisan command.
I anyone looking into this? APP_URL seems to NOT be set in Lumen.
My solution was to switch to Laravel. It seems Lumen is too restricted for anything too serious.
I just did the configuration part the application URL configurable, you could update the application to import a local configuration.
Let鈥檚 first create a config folder and copy the app configuration:
$ mkdir config/
$ cp vendor/laravel/lumen-framework/config/app.php config/
Next, open the config/app.php file and add the following somewhere to the array:
'url' => env('APP_URL', 'http://localhost'),
Last, you need to register the configuration file by adding the following line to the bootstrap/app.php file after the application instance is created:
$app->configure('app');
Font: https://laravel-news.com/using-named-routes-lumen-test
Most helpful comment
+1. getting 'http://:/' anytime i access url() from phpunit/artisan command.