【问题标题】:Laravel and WordPress IntegrationLaravel 和 WordPress 集成
【发布时间】: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 之外包含路径时会出现问题。但是博客文件夹在里面。

【问题讨论】:

标签: wordpress laravel


【解决方案1】:

我刚刚修改了路径

protected $bootstrapFilePath = 'blog/wp-load.php';

它有效。

【讨论】:

    猜你喜欢
    • 2020-09-06
    • 2014-07-12
    • 2017-07-28
    • 1970-01-01
    • 2016-04-05
    • 2020-02-28
    • 2016-11-14
    • 2013-09-10
    • 2013-01-27
    相关资源
    最近更新 更多