Understanding Routing in Laravel
I started my project using Laravel, but I don't know how routing works.
Example code:
Route::get('/', function () {
return view('welcome');
});
Where is the get static function? I searched in the Laravel /vendor directory but found nothing.
laravel laravel-5 laravel-routing
add a comment |
I started my project using Laravel, but I don't know how routing works.
Example code:
Route::get('/', function () {
return view('welcome');
});
Where is the get static function? I searched in the Laravel /vendor directory but found nothing.
laravel laravel-5 laravel-routing
1
You should use github.com/barryvdh/laravel-ide-helper to generate an IDE helper file that allows you to get type hints in your IDE and also contains some information on where functions are from
– apokryfos
Nov 25 '18 at 13:56
add a comment |
I started my project using Laravel, but I don't know how routing works.
Example code:
Route::get('/', function () {
return view('welcome');
});
Where is the get static function? I searched in the Laravel /vendor directory but found nothing.
laravel laravel-5 laravel-routing
I started my project using Laravel, but I don't know how routing works.
Example code:
Route::get('/', function () {
return view('welcome');
});
Where is the get static function? I searched in the Laravel /vendor directory but found nothing.
laravel laravel-5 laravel-routing
laravel laravel-5 laravel-routing
edited Nov 26 '18 at 5:25
Karl Hill
3,13622344
3,13622344
asked Nov 25 '18 at 12:49
DeLeDeLe
44242755
44242755
1
You should use github.com/barryvdh/laravel-ide-helper to generate an IDE helper file that allows you to get type hints in your IDE and also contains some information on where functions are from
– apokryfos
Nov 25 '18 at 13:56
add a comment |
1
You should use github.com/barryvdh/laravel-ide-helper to generate an IDE helper file that allows you to get type hints in your IDE and also contains some information on where functions are from
– apokryfos
Nov 25 '18 at 13:56
1
1
You should use github.com/barryvdh/laravel-ide-helper to generate an IDE helper file that allows you to get type hints in your IDE and also contains some information on where functions are from
– apokryfos
Nov 25 '18 at 13:56
You should use github.com/barryvdh/laravel-ide-helper to generate an IDE helper file that allows you to get type hints in your IDE and also contains some information on where functions are from
– apokryfos
Nov 25 '18 at 13:56
add a comment |
2 Answers
2
active
oldest
votes
Actually, you are using Route Facade. Which facilitates to access object members in static environment. Facades uses __callStatic magic method of PHP.
Study the Facades here.
add a comment |
Laravel routes are very simple, they keep your project neatly organized. The routes are usually the best place to look to understand an application is linked together.
The Laravel documentation on routing is very elaborate.
The example you sited is an example of a GET route to the / URL.
It accepts a callback as a second parameter. This callback determines how the request is processed. In this case, a view response is returned.
Route::get('/', function () {
return view('welcome');
});
There are different types of routes:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
You can also pass parameters through your routes:
You may define as many route parameters as required by your route:
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
// });
Sometimes you may need to register a route that responds to multiple
HTTP verbs. You may do so using the match method. Or, you may even
register a route that responds to all HTTP verbs using the any method:
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('foo', function () {
//
});
Here is a good piece on the subject.
1
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467598%2funderstanding-routing-in-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Actually, you are using Route Facade. Which facilitates to access object members in static environment. Facades uses __callStatic magic method of PHP.
Study the Facades here.
add a comment |
Actually, you are using Route Facade. Which facilitates to access object members in static environment. Facades uses __callStatic magic method of PHP.
Study the Facades here.
add a comment |
Actually, you are using Route Facade. Which facilitates to access object members in static environment. Facades uses __callStatic magic method of PHP.
Study the Facades here.
Actually, you are using Route Facade. Which facilitates to access object members in static environment. Facades uses __callStatic magic method of PHP.
Study the Facades here.
answered Nov 25 '18 at 12:59
Jamal Abdul NasirJamal Abdul Nasir
1,30331639
1,30331639
add a comment |
add a comment |
Laravel routes are very simple, they keep your project neatly organized. The routes are usually the best place to look to understand an application is linked together.
The Laravel documentation on routing is very elaborate.
The example you sited is an example of a GET route to the / URL.
It accepts a callback as a second parameter. This callback determines how the request is processed. In this case, a view response is returned.
Route::get('/', function () {
return view('welcome');
});
There are different types of routes:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
You can also pass parameters through your routes:
You may define as many route parameters as required by your route:
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
// });
Sometimes you may need to register a route that responds to multiple
HTTP verbs. You may do so using the match method. Or, you may even
register a route that responds to all HTTP verbs using the any method:
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('foo', function () {
//
});
Here is a good piece on the subject.
1
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
add a comment |
Laravel routes are very simple, they keep your project neatly organized. The routes are usually the best place to look to understand an application is linked together.
The Laravel documentation on routing is very elaborate.
The example you sited is an example of a GET route to the / URL.
It accepts a callback as a second parameter. This callback determines how the request is processed. In this case, a view response is returned.
Route::get('/', function () {
return view('welcome');
});
There are different types of routes:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
You can also pass parameters through your routes:
You may define as many route parameters as required by your route:
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
// });
Sometimes you may need to register a route that responds to multiple
HTTP verbs. You may do so using the match method. Or, you may even
register a route that responds to all HTTP verbs using the any method:
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('foo', function () {
//
});
Here is a good piece on the subject.
1
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
add a comment |
Laravel routes are very simple, they keep your project neatly organized. The routes are usually the best place to look to understand an application is linked together.
The Laravel documentation on routing is very elaborate.
The example you sited is an example of a GET route to the / URL.
It accepts a callback as a second parameter. This callback determines how the request is processed. In this case, a view response is returned.
Route::get('/', function () {
return view('welcome');
});
There are different types of routes:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
You can also pass parameters through your routes:
You may define as many route parameters as required by your route:
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
// });
Sometimes you may need to register a route that responds to multiple
HTTP verbs. You may do so using the match method. Or, you may even
register a route that responds to all HTTP verbs using the any method:
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('foo', function () {
//
});
Here is a good piece on the subject.
Laravel routes are very simple, they keep your project neatly organized. The routes are usually the best place to look to understand an application is linked together.
The Laravel documentation on routing is very elaborate.
The example you sited is an example of a GET route to the / URL.
It accepts a callback as a second parameter. This callback determines how the request is processed. In this case, a view response is returned.
Route::get('/', function () {
return view('welcome');
});
There are different types of routes:
Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);
You can also pass parameters through your routes:
You may define as many route parameters as required by your route:
Route::get('posts/{post}/comments/{comment}', function ($postId, $commentId) {
// });
Sometimes you may need to register a route that responds to multiple
HTTP verbs. You may do so using the match method. Or, you may even
register a route that responds to all HTTP verbs using the any method:
Route::match(['get', 'post'], '/', function () {
//
});
Route::any('foo', function () {
//
});
Here is a good piece on the subject.
edited Nov 28 '18 at 13:43
answered Nov 25 '18 at 12:56
Elisha SenooElisha Senoo
1,2852818
1,2852818
1
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
add a comment |
1
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
1
1
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
Nice general info but does not actually answer the only question the OP asked.
– Don't Panic
Nov 25 '18 at 15:17
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53467598%2funderstanding-routing-in-laravel%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You should use github.com/barryvdh/laravel-ide-helper to generate an IDE helper file that allows you to get type hints in your IDE and also contains some information on where functions are from
– apokryfos
Nov 25 '18 at 13:56