Lumen: getting an url parameter within a Blade view

NOTE: from the release of Lumen 5.2 views are no longer included with the framework since it is strongly focused on building stateless APIs. The code below works up to Lumen 5.1.

The following code can be used in Lumen, within a Blade view, in order to get the current value of a url parameter:

{{ app('request')->input('name') }}

Where name is the url parameter name.

Example

Given the following url:

http://localhost:8000/example?company=netgloo

The following code:

{{ app('request')->input('company') }}

will print out the string “netgloo”.

References

http://laravel.com/api/5.0/Illuminate/Http/Request.html
http://stackoverflow.com/questions/30239296/howto-get-url-facade-in-lumen-blade-template

  • ori

    The Blade views just disappeared from the documentation, but are still present in Lumen 5.2. And since it’s a LTS release, It’s a safe bet to say they are there to stay.

    • Hello, thank you for the clarification.

      In the Lumen 5.2.0’s release note I linked above, it is written this:

      […] As such, sessions and views are no longer included with the framework. If you need access to these features, you should use the full Laravel framework. […]

      It sounds like the use of views within Lumen is discouraged.

Categories

Category BootstrapCategory CoffeescriptCategory DrupalCategory GravCategory HTMLCategory JavascriptCategory JoomlaCategory jQueryCategory LaravelCategory MagentoCategory PHPCategory SharePointCategory SpringCategory ThymeleafCategory WordPressCategory Workflow

Comments

Developed and designed by Netgloo
© 2019 Netgloo