我正在开发一个工作正常的项目,我现在已经恢复了项目的备份,项目和备份是相同的,我还将备份名称更改为原始名称,现在更改为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', 'UserController@getLogin');
当我在网络浏览器中输入/密码时,它的工作正常。输出是:
$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并没有记录任何内容。似乎这个功能没有执行。
为什么控制器无法正常工作?
我的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)
{
//
}
}
答案 0 :(得分:2)
您使用了错误的地址来访问/login
路由,它应该是:
http://project/login
如果它不起作用,您还需要通过设置document root to laravel_project/public
directory来设置网络服务器。
此外:
/storage/logs/laravel.log
是否有错误storage
文件夹及其中的所有文件和文件夹设置正确的权限 php artisan cache:clear
php artisan route:clear
答案 1 :(得分:0)
您正在使用Hash
外观,但未在use
语句中声明它的使用。
PHP尝试解析'App \ Http \ Controllers`命名空间中的类,从而尝试查找不存在的App\Http\Controllers\Hash
类。
在文件中添加use Hash;
可以解决您的问题。
use Auth;
use Log;
use Hash;