Skip to content

Add Routing Wildcard '(:all)' to Documentation #1132

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

Merged
merged 1 commit into from
Sep 2, 2012
Merged

Add Routing Wildcard '(:all)' to Documentation #1132

merged 1 commit into from
Sep 2, 2012

Conversation

cmenke
Copy link

@cmenke cmenke commented Aug 21, 2012

Found an (:all) selector in the source, might be worth adding.

http://laravel.com/api/source-class-Laravel.Routing.Router.html#79

public static $patterns = array(
         '(:num)' => '([0-9]+)',
         '(:any)' => '([a-zA-Z0-9\.\-_%]+)',
         '(:all)' => '(.*)',
);

@tobsn
Copy link
Contributor

tobsn commented Aug 21, 2012

hmm, that is pretty redundant...

@Anahkiasen
Copy link
Contributor

That being said, I didn't get until that PR that you could actually write any regex in there. I'm ashamed.

@cmenke
Copy link
Author

cmenke commented Aug 22, 2012

It's not redundant, because (:all) includes all characters, most importantly slashes – as opposed to (:any), which only returns a segment. I found this very useful to protect a folder, though there surely are other use cases.

Route::get('files/(:all)', array('before' => 'auth', function($path)
{
    $path = path('storage') . 'files/' . $path;
    if (File::exists($path))
    {
        return Response::download($path, 'smth');
    }
    return Response::error('404');
}));

With (:any), the Route would have to look something like this:

Route::get('files/(:any)/(:any?)/(:any?)', array('before' => 'auth', function($param1, $param2=null, $param3=null)
{
    $path = path('storage') . 'files/' . $param1 . '/' . $param2 . '/' . $param3;
...

taylorotwell added a commit that referenced this pull request Sep 2, 2012
Add Routing Wildcard '(:all)' to Documentation
@taylorotwell taylorotwell merged commit 50b10fc into laravel:master Sep 2, 2012
zoe-edwards pushed a commit to zoe-edwards/laravel that referenced this pull request Oct 14, 2013
…d-depth

Find autoload files for packages that aren't in a vendor/package directory structure.
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.

4 participants