运行 在 Lumen 中建模时出错
Error while running models in Lumen
这是我的报表模型
namespace App;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
protected $fillable = ['ApiKey', 'Success', 'Error', 'Token', 'Password'];
protected $hidden = ['Token'];
}
在我的控制器中我有这个:
namespace App\Http\Controllers;
use Illuminate\Database\Schema\Blueprint;
use App\Report;
我没有收到任何错误,绝对没有任何反应,但我通过代码使用 运行 die()
命令对其进行了测试,程序在 $report = new Report
处停止
在我的家用计算机 XAMPP 上,此代码有效,但在远程服务器上无效。
这不仅适用于此模型,适用于代码中的所有模型。
我有 Apache,Ubuntu,PHP 5.5 和 Lumen
正如上面评论中所讨论的,用户是错误的,由于缺少权限,lumen 无法访问模型文件。您应该将用户更改为 www-data
并在应用程序的文件夹上设置 775 权限:
sudo chown -R www-data:www-data <path/to/application>
sudo chmod -R 775 <path/to/application>
这是我的报表模型
namespace App;
use Illuminate\Database\Eloquent\Model;
class Report extends Model
{
protected $fillable = ['ApiKey', 'Success', 'Error', 'Token', 'Password'];
protected $hidden = ['Token'];
}
在我的控制器中我有这个:
namespace App\Http\Controllers;
use Illuminate\Database\Schema\Blueprint;
use App\Report;
我没有收到任何错误,绝对没有任何反应,但我通过代码使用 运行 die()
命令对其进行了测试,程序在 $report = new Report
在我的家用计算机 XAMPP 上,此代码有效,但在远程服务器上无效。
这不仅适用于此模型,适用于代码中的所有模型。
我有 Apache,Ubuntu,PHP 5.5 和 Lumen
正如上面评论中所讨论的,用户是错误的,由于缺少权限,lumen 无法访问模型文件。您应该将用户更改为 www-data
并在应用程序的文件夹上设置 775 权限:
sudo chown -R www-data:www-data <path/to/application>
sudo chmod -R 775 <path/to/application>