Support the ongoing development of Laravel.io →
posted 10 years ago
Views

Hi Laravel friends!

Where to tell Artisan the right base url?

I use Laravel in a subfolder like http://mysuperserver/laravel/ When I call it from Browser all works fine, all generated urlss are right.

But if I use a custom Artisan command the generated url's are like http://mysuperserver/ without the subfolder.

in app/config/app.php I set the url but thats doesn't work.

 /*
        |--------------------------------------------------------------------------
        | Application URL
        |--------------------------------------------------------------------------
        |
        | This URL is used by the console to properly generate URLs when using
        | the Artisan command line tool. You should set this to the root of
        | your application so that it is used when running Artisan tasks.
        |
        */

        'url' => 'http://mysuperserver/laravel/',

My custom command run a controller function -> a model -> get data from db -> back to controller -> make view -> in view -> {{ link_to_route('my.named.route') }}

From HTTP all generated url's = fine.

From Artisan generaded url's != fine.

Last updated 2 years ago.
0

Hi there! How did you set up your application environments under bootstrap/start.php ?

If your running on local environment you might have to create a seperate config file under app/config/local/app.php and set the Application URL for artisan right there.

I think you can even specifiy the env when running your artisan command like this

# php artisan some:task --env=local

hope that helps.

Last updated 2 years ago.
0

Hi all!

I'm having the same issue. Does somebody have a workaround?

Last updated 2 years ago.
0

Hi,

Encountered same issue. Also posted question here: http://stackoverflow.com/questions/25750604/laravel-artisan-gives-wrong-base-url

Moved past this using Config::get('app.url') instead.

Hope this helps!

Last updated 2 years ago.
0

Hi medowlock,

Thanks, I did the same workaround as you suggested, but would be good to have this corrected in future laravel versions.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

nixis nixis Joined 21 May 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.