0

I have a working Corcel/Laravel integration that works fine to process Wordpress posts. But using Corcel means that you miss out on the functionalities of the Wordpress environment e.g using contents and shortcodes from plugins.

But I am worried about including Wordpress in Laravel for performance reasons because each of the Laravel and Wordpress are quite huge applications with hundreds of processes to display a single page.

I feel like running the two together may become impractical as an application grows due too many resources on a simple regular hosting server.

Is it really overkill on a regular hosting server to run all the process in Laravel and also all in Wordpress just to serve a single page?

Is there a recommended execution time for serving a page and how can I check the execution time properly in PHP?

Ghanshyam Nakiya
  • 1,602
  • 17
  • 24
Chika
  • 25
  • 5

1 Answers1

0

You need to rethink your whole app architecture. There is no point of running WP and Laravel in parallel.

Let WP do content management things, and let Laravel to do whatever Laravel does.

Any reasonable server will be able to run both in parallel, however that adds a lot of complexity and a potential maintenance nightmare.

These guidelines from Google advises having a response time of 100-500ms including the rendering of the frontend.

You can use microtime() to measure script execution time.

Eriks Klotins
  • 4,042
  • 1
  • 12
  • 26
  • Wordpress will still only handle post content management but adding it into Laravel only helps to nicely fetch and process the contents better than using Corcel or the likes. I am not sure why you believe it is a maintenance nightmare when Wordpress will just work as an independent module that provide extra functions, and can be maintained separately from Laravel? I guess it is normal in PHP to extend functions by including external modules. Why do you think it is bad to do the same thing people are doing with Corcel with Wordpress? Or do you have or foresee any potential issue? – Chika Jun 11 '19 at 10:24
  • WP as an independent module is fine. Why do you want to 'process the contents' with Laravel? – Eriks Klotins Jun 11 '19 at 10:34
  • The application requires better access management system and interactivity than WordPress offers. Laravel will handle user management and interactivity while WordPress manage and fetch public posts for Laravel to display. I guess WordPress is not adequate for a full web app but it is very good for content management and for non heavily interactive site? – Chika Jun 11 '19 at 11:07
  • What exactly do you mean by interactivity? I would write a WP plugin providing custom functionality. Laravel provides you only an MVC scaffolding that is useful for larger projects. Perhaps, if your plugin turns out large and complex you can use some modules of Laravel, e.g. Doctirne, templating etc, to make things easier. – Eriks Klotins Jun 11 '19 at 11:42
  • the interactivity includes users posting items and questions, other members responding with answers likes and comments. there are user area and admin area to monitor site activities and authorise access to different part of the site. Each normal page can define its own sidebar, rightbar and footer and main/sub menu content content. I have written plugin in WP in the past but it was all too spaghetti coding; though things might have changed now. Its quite interesting that you said that Laravel only provides MVC with all that overhead, which actually makes me think twice about it now. – Chika Jun 11 '19 at 20:57
  • @Chika If you use MVC, templates (Pug, twig or similar,), separate data access from your logic (use reasonable file/folder structure), write testable classes, the result is a quite maintainable plugin without the overhead of booting up the whole Laravel framework. – Eriks Klotins Jun 12 '19 at 06:43
  • My main concerns would be how to deal with two data access layers. You cannot use both at the same time. It would make more sense to use WP api, however then you lose the ORM part of Laravel. This leaves you with controllers/views alone. Using ORM without the WP API would impair WP functionality, mess up other plugins, and could create upgrade issues – Eriks Klotins Jun 12 '19 at 06:51
  • Thanks for lots of insights, and now I know the only issue is not due to response time. I will try out the suggestions in your answer at the weekend – Chika Jun 12 '19 at 08:39
  • I have a use case, say a tourbooking website. The content is complex, I want Wordpress to manage it with sliders, forms, menu, sidebars etc... I want the booking system to be handled by Laravel. I want the user to feel a seamless application, ie: same menu, styling in all pages etc... What's the best approach? – Azmeer Jun 05 '21 at 16:53
  • @Azmeer please read my answer and the comments. Trying to mix WP with Laravel creates more problems than it solves. – Eriks Klotins Jun 07 '21 at 20:49