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.