Laravel和Wordpress前端

I am building a web app on Laravel, which involves logins by multiple user types etc.

I would like to use Wordpress backend and frontend for most the CMS related stuff. I want to Wordpress frontend, as it is easier to maintain for the client, and a lot of the site's user facing pages are content that can be from wordpress.

I want the site to show pages from wordpress, if the route is not being handled by Laravel.

http://webapp.com/ -> (Landing Page)from Wordpress

http://webapp.com/laravelRoute -> Laravel

http://webapp.com/some-post-url -> Wordpress.

How can I achieve this by letting Laravel and Wordpress play nice with routing?

I've tried installing Wordpress in public/ folder. However it doesn't recognise Laravel routes, works like a general wordpress site.

Here's how I was able to fix it.

http://example.com/ -> Laravel code

<laravel code root>/public/pages -> wordpress code

You should be able to access http://example.com/pages/ -> from the wordpress content.

You also need to configure nginx to handle Wordpress URL redirects:

        ...
        location /pages/index.php(/.*)?$ {        
            fastcgi_split_path_info ^(/pages/index.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_read_timeout 1000;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            include fastcgi_params;
        }
        location /pages/ { 
            if (!-e $request_filename) {
                    rewrite ^.*$ /pages/index.php last;    
                }
            try_files $uri $uri/ pages/index.php?args; 
        }
        location / { ...

To merge both Laravel and Wordpress on the same level you have two options or maybe more.

The first option is to setup .htaccess rewrite rules and redirect all Laravel routes to a laravel-index.php file. You rename the Laravel app index.php file to that.

The second option is to disable the wordpress index.php file and instead use Laravel's. In laravel create a catch all route that call the Wordpress object. So with this method, all you have to do is create the Laravel routes and the rest will just fall through to Wordpress.