我正在開發一個工作正常的項目,現在我已經恢復了項目的備份,項目和備份完全相同,我還將備份名稱更改爲原來的名字,現在route.php中的控制器不起作用。控制器不能在Laravel的route.php中工作
對於做備份和恢復它,我做了
cp -r project/ project_backup
rm -r project
cp -r project_backup/ project
在我的routes.php文件我有:
<?php
/*
|--------------------------------------------------------------------------
| Routes File
|--------------------------------------------------------------------------
|
| Here is where you will register all of the routes in an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the controller to call when that URI is requested.
|
*/
/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| This route group applies the "web" middleware group to every route
| it contains. The "web" middleware group is defined in your HTTP
| kernel and includes session state, CSRF protection, and more.
|
*/
Route::get("/password", function(){
$password = Hash::make('12345678');
echo $password;
});
Route::get('/login', '[email protected]');
當我在/密碼,在Web瀏覽器中輸入其做工精細。輸出是:
$2y$10$.grNtTpANndXN0V3/rn9buSO470jPEeVWVyc00rupU6iNt9G.DMZC
但是,當我在/登錄進入我得到
GET http://project/public/index.php/login [HTTP/1.0 500內部服務器錯誤247ms]
在我UserController中我有:
public function getLogin(){
Log::info("getLogin");
$password = Hash::make('12345678');
echo $password;
}
實際上,laravel.log doesn不記錄任何東西。看起來這個功能沒有執行。
爲什麼控制器不起作用?
我laravel的版本是:
Laravel Framework版本5.2.30
感謝
編輯:UserController.php代碼
<?php
namespace Ordered\Http\Controllers;
use Ordered\User;
use Illuminate\Http\Request;
use Ordered\Http\Requests;
use Auth;
use Log;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
//
$user = User::all();
return response()->json(["error"=>false, "data"=>$user->load("bars")],200);
}
public function getLogin(){
Log::info("getLogin");
$password = Hash::make('12345678');
echo $password;
}
public function postLogin(Request $request){
$input = $request->all();
Log::info($input["email"]);
Log::info($input["password"]);
if (Auth::attempt(['email' => $input["email"], 'password' => $input["password"]], true))
{
Log::info("postInfo");
return redirect()->intended('/tables');
}
}
public function apiLogin(Request $request){
$input = $request->all();
if (Auth::attempt(['username' => $request->header("u"), 'password' => $request->header("p")]))
{
return response()->json(["error"=>false, "data"=>Auth::user()->load("bars")],200);
}
return response()->json(["error"=>true, "data"=>""],401);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
//
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
//
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}
您可以粘貼UserController的內容嗎? – osleonard
就像@osleonard說的那樣,如果你發佈'UserController'源代碼就好了。 – Skysplit
我已經更新了帖子的源代碼。謝謝 – RdlP