2016-08-29 11 views
44

हाल ही में मैं laravel 5.3 उपयोग करने के लिए एक ब्लॉग लिखने के लिए शुरू करते हैं, लेकिन मैं चलाने के बाद एक सवाल php artisan make:authlaravel 5.3 नई प्रमाणीकरण :: मार्गों()

जब मैं इस चलाने के लिए, यह मेरे web.php

में मार्गों उत्पन्न होगा है

इस उस में कोड है:

Auth::routes(); 

Route::get('/home', '[email protected]'); 

तब मैं चलाने php artisan route:list, मैं LoginController @ लॉगिन की तरह कार्रवाई की बहुत सारी, लगता है ...

लेकिन मुझे इन कार्यों को मेरे App\Http\Controllers\Auth में नहीं मिला, ये कहां हैं?

और Auth::routes() के लिए भी खड़े हैं, मुझे Auth के बारे में मार्ग नहीं मिल रहे हैं।

मैं किसी को मदद की जरूरत है, तुम मेरे सवाल का जवाब देने का शुक्रिया अदा

उत्तर

84

प्रमाणीकरण :: मार्गों() सिर्फ एक सहायक वर्ग में मदद करता है कि आप सभी उपयोगकर्ता प्रमाणीकरण के लिए आवश्यक मार्गों उत्पन्न होने का कहता है। आप इसके बजाय कोड https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php पर ब्राउज़ कर सकते हैं।

यहाँ मार्गों

// Authentication Routes... 
$this->get('login', 'Auth\[email protected]')->name('login'); 
$this->post('login', 'Auth\[email protected]'); 
$this->post('logout', 'Auth\[email protected]')->name('logout'); 

// Registration Routes... 
$this->get('register', 'Auth\[email protected]')->name('register'); 
$this->post('register', 'Auth\[email protected]'); 

// Password Reset Routes... 
$this->get('password/reset', 'Auth\[email protected]'); 
$this->post('password/email', 'Auth\[email protected]'); 
$this->get('password/reset/{token}', 'Auth\[email protected]'); 
$this->post('password/reset', 'Auth\[email protected]'); 
+0

धन्यवाद! मैं ../Routing/Router.php देखता हूं और अब मुझे पता है कि मार्ग कैसे काम करते हैं। लेकिन ऑथ स्थैतिक विधि मार्ग() कहां है? मुझे अभी भी यह नहीं मिल रहा है, मुझे माफ़ कर दो मैं एक लार्वा शुरुआत कर रहा हूं ... – g1eny0ung

+1

एथ :: मार्ग विधि यहां है https://github.com/laravel/framework/blob/5.3/src/Illuminate/Support/Facades/ Auth.php और राउटर फ़ंक्शन को वैसे भी कॉल करना। अगर यह आपकी मदद करता है, तो कृपया इसे उत्तर के रूप में चिह्नित करें, धन्यवाद। – Lee

+1

'ऑथ' एक * मुखौटा * है और इसे 'config/app.php' में परिभाषित किया जाएगा, आपको उस कॉन्फ़िगरेशन फ़ाइल में उस प्रदाता के रूप में कार्य करने वाली कक्षा मिल जाएगी। – Jason

0

loginuser वर्ग एक विशेषता है कहा जाता है का उपयोग करता है AuthenticatesUsers

आपको लगता है कि विशेषता आप कार्यों देखेंगे (यह अन्य नियंत्रकों के लिए लागू होता है) को खोलने अगर Illuminate\Foundation\Auth\AuthenticatesUsers;

यहाँ विशेषता कोड बुरा प्रारूप के लिए https://github.com/laravel/framework/blob/5.1/src/Illuminate/Foundation/Auth/AuthenticatesUsers.php

खेद है, im मेरे फोन का उपयोग कर

भी Auth::routes() यह सिर्फ एक समारोह है कि प्रमाणन मार्गों यह thats (मुझे लगता है कि)

+0

हाँ, मैं प्रमाणीकरण/dir के माध्यम से देखते हैं, लेकिन मैं विधि, अनुप्रयोग की तरह नहीं मिल रहा \ http \ नियंत्रकों \ प्रमाणीकरण \ ResetPasswordController @ showResetForm, जहां मैं @ के बाद विधि पा सकते हैं, मैं खर्च इसे खोजने के लिए काफी समय है, लेकिन अब मैं इसे भी नहीं ढूंढ सकता .. मैं लार्वेल के लिए नया हूं .. – g1eny0ung

+1

यहां पूरा रास्ता 'विक्रेता \ laravel \ src \ Illuminate \ Foundation \ Auth \ ResetsPasswords' है, अगर आप चाहते हैं इसे या कुछ बदलें, इसे न बदलें, बस अपने नियंत्रक को एक ही विधि जोड़ें और फिर इसे बदलें, –

+0

@ आर्चफ खुदाजा, ऐसा लगता है कि आप मास्टर लार्वेल हैं। मैं तुम्हारी मदद चाहता हूँ। यहां देखें: http://stackoverflow.com/questions/41047583/how-to-add- गतिशील- ड्रोपडाउन-list-column-on-laravel-5-3- पंजीकरण –

31

Laravel 5.3 बजाय प्रमाणीकरण :: मार्गों() के लिए प्रमाणीकरण रास्ते हैं। मुझे आशा है कि यह मदद करता है ...

Route::group(['middleware' => ['web']], function() { 

// Login Routes... 
    Route::get('login', ['as' => 'login', 'uses' => 'Auth\[email protected]m']); 
    Route::post('login', ['as' => 'login.post', 'uses' => 'Auth\[email protected]']); 
    Route::post('logout', ['as' => 'logout', 'uses' => 'Auth\[email protected]']); 

// Registration Routes... 
    Route::get('register', ['as' => 'register', 'uses' => 'Auth\[email protected]']); 
    Route::post('register', ['as' => 'register.post', 'uses' => 'Auth\[email protected]']); 

// Password Reset Routes... 
    Route::get('password/reset', ['as' => 'password.reset', 'uses' => 'Auth\[email protected]']); 
    Route::post('password/email', ['as' => 'password.email', 'uses' => 'Auth\[email protected]']); 
    Route::get('password/reset/{token}', ['as' => 'password.reset.token', 'uses' => 'Auth\[email protected]']); 
    Route::post('password/reset', ['as' => 'password.reset.post', 'uses' => 'Auth\[email protected]']); 
}); 

तो अगर आप इन मार्गों में से कुछ के नाम बदलने के लिए, यह भी देखा गया पदों की कार्रवाई में बदलने के लिए याद!

2

समारोह कॉल आदेश:

  1. (प्रमाणीकरण) रोशन \ Support \ Facades \ प्रमाणीकरण @ मार्गों (https://github.com/laravel/framework/blob/5.3/src/Illuminate/Support/Facades/Auth.php)
  2. (अनुप्रयोग) रोशन \ फाउंडेशन \ Application @ प्रमाणन
  3. (मार्ग) रोशन \ रूटिंग \ रूटर

इसे इस तरह मार्ग है:

public function auth() 
{ 
    // Authentication Routes... 
    $this->get('login', 'Auth\[email protected]'); 
    $this->post('login', 'Auth\[email protected]'); 
    $this->get('logout', 'Auth\[email protected]'); 
    // Registration Routes... 
    $this->get('register', 'Auth\[email protected]'); 
    $this->post('register', 'Auth\[email protected]'); 
    // Password Reset Routes... 
    $this->get('password/reset/{token?}', 'Auth\[email protected]'); 
    $this->post('password/email', 'Auth\[email protected]'); 
    $this->post('password/reset', 'Auth\[email protected]'); 
} 
+0

https://github.com/laravel/framework/blob/5.3/src/Illuminate/Routing/Router.php#L298 –

7

लार्वेल 5.5 के लिए।एक्स

// Authentication Routes... 
$this->get('login', 'Auth\[email protected]')->name('login'); 
$this->post('login', 'Auth\[email protected]'); 
$this->post('logout', 'Auth\[email protected]')->name('logout'); 

// Registration Routes... 
$this->get('register', 'Auth\[email protected]')->name('register'); 
$this->post('register', 'Auth\[email protected]'); 

// Password Reset Routes... 
$this->get('password/reset', 'Auth\[email protected]')->name('password.request'); 
$this->post('password/email', 'Auth\[email protected]')->name('password.email'); 
$this->get('password/reset/{token}', 'Auth\[email protected]')->name('password.reset'); 
$this->post('password/reset', 'Auth\[email protected]'); 
संबंधित मुद्दे