Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.3] Change server variables when bootstrapping the app request from artisan. #15608

Closed
wants to merge 1 commit into from

Conversation

j3j5
Copy link
Contributor

@j3j5 j3j5 commented Sep 26, 2016

This change fixes #14139 .

I am not sure where would tests for this belong. Should they go on tests/Routing/RoutingUrlGeneratorTest.php or on tests\Console\ConsoleApplicationTest.php? I think the former is better but I'd like to have somebody else opinion.

@taylorotwell
Copy link
Member

I'm not able to even recreate this: http://d.pr/i/1bqOj

@vlakoff
Copy link
Contributor

vlakoff commented Nov 25, 2016

A better fix in SetRequestForConsole might be:

    public function bootstrap(Application $app)
    {
        $url = $app->make('config')->get('app.url', 'http://localhost');

        // Add this line:
        $app->make('url')->forceRootUrl($url);

        $app->instance('request', Request::create($url, 'GET', [], [], [], $_SERVER));
    }

The user is still able to call again forceRootUrl later if he wishes so.


Alternatively, this could be added to RoutingServiceProvider:

if ($app->runningInConsole()) {
    $url->forceRootUrl($app['config']->get('app.url', 'http://localhost'));
}


Though in both suggestions, we're introducing new dependencies into the service providers:

  1. 'url' into SetRequestForConsole
  2. 'config' into RoutingServiceProvider / 'url'

@j3j5 j3j5 deleted the 5.3 branch August 8, 2018 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants