【发布时间】:2018-11-11 07:57:48
【问题描述】:
为了包含 wordpress,我创建了一个服务提供者。
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\File;
class WordpressCustomServiceProvider extends ServiceProvider
{
protected $bootstrapFilePath = '../../blog/wp-load.php';
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
// wp_enqueue_style('app', '/app/public/app.css');
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//echo dirname(__FILE__); die;
//
// Load wordpress bootstrap file
if(File::exists($this->bootstrapFilePath)) {
require_once $this->bootstrapFilePath;
} else throw new \RuntimeException('WordPress Bootstrap file not found!');
}
}
我还包含在 app.php 的提供者列表中的类中 当我运行代码时。它给了我错误:
"file_exists(): open_basedir 限制生效。 文件(../../blog/wp-load.php)不在允许的路径内: (/var/www/vhosts/ser.com/:/tmp/)"
我的博客结构是这样的:
app/ ---->Laravel
blog/ ---->wordpress
是的,我知道当我们在 webroot 之外包含路径时会出现问题。但是博客文件夹在里面。
【问题讨论】: