laravel学习日记-基本路由
in PHP with 0 comment

laravel学习日记-基本路由

in PHP with 0 comment

基本路由

Route::get('/', function () {
    return 'Hello World';
});

Route::post('foo/bar', function () {
    return 'Hello World';
});

Route::put('foo/bar', function () {
    //
});

Route::delete('foo/bar', function () {
    //
});

因为这是最佳实践,一开始做对了,后面节省你重构代码的时间;
路由缓存 并不会作用在基于闭包的路由。

为多重动作注册路由

有时候你可能需要注册一个可响应多个 HTTP 动作的路由。这时可通过 Route facade 的 match 方法来实现:

Route::match(['get', 'post'], '/', function () {
    return 'Hello World';
});

甚至可以通过 any 方法来使用注册路由并响应所有的 HTTP 动作:


Route::any('foo', function () {
    return 'Hello World';
});

生成 URLs 路由

url 辅助函数生成 URL:

$url = url('foo');
dump($url);

上述代码将输出:

"http://laravel.me/index.php/foo"
Responses
icon_mrgreen.gificon_neutral.gificon_twisted.gificon_arrow.gificon_eek.gificon_smile.gificon_confused.gificon_cool.gificon_evil.gificon_biggrin.gificon_idea.gificon_redface.gificon_razz.gificon_rolleyes.gificon_wink.gificon_cry.gificon_surprised.gificon_lol.gificon_mad.gificon_sad.gificon_exclaim.gificon_question.gif
  1. @

    Viagra Schweiz Bestellen buy viagra Acheter Cialis Ligne Pas Cher Comprar Cialis Medicamento Certified Online Meds Progesterone Medication Secure Ou Acheter Du Viagra En Suisse Sildenafil Generique 20 Mg Salzarex Pharmaceuticals Generic Viagra Cheapest Brand Name Levitra

    Reply
  2. @

    Generique Levitra viagra Amoxicillin Is It Penicillin Cialis 20 Mg Paypal Good Site To Buy Viagra Kamagra Prescrizione Germania Meglio Levitra O Viagra brandlevitra on line Apodefil Kamagra Cialis Ricetta Medica cialis Amoxicillin And Methadone Cialis Viagra Preisvergleich Amoxicillin And Clavulante Potassium Tablets Posso Comprar Cialis Farmacia generic viagra Kamagra In Canada Dosis Kamagra Jelly

    Reply