0

I have created a service provider in order to include 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!');
    }
}

I have also included in class in provider list in app.php When i run the code. It gives me the error:

"file_exists(): open_basedir restriction in effect. File(../../blog/wp-load.php) is not within the allowed path(s): (/var/www/vhosts/ser.com/:/tmp/)"

My Blog Structure is like:

app/  ---->Laravel
blog/ ---->wordpress

Yes I know the problem comes when we include path outside webroot. But blog folder is inside.

Stephen Lake
  • 1,582
  • 2
  • 18
  • 27
Intekhab Khan
  • 1,775
  • 4
  • 18
  • 28
  • Possible duplicate of [open\_basedir restriction in effect. File(/) is not within the allowed path(s):](https://stackoverflow.com/questions/1846882/open-basedir-restriction-in-effect-file-is-not-within-the-allowed-paths) – Stephen Lake Nov 11 '18 at 08:41

1 Answers1

-1

I just modified the path

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

and it works.

Intekhab Khan
  • 1,775
  • 4
  • 18
  • 28