0

I have written 4 PHP Applications using Zend Framework 2 with 1 module in each of them. All these PHP applications have the same header, footer and layout, but different content in them. Each module serves it's own purpose.

What is the best way to share css, js and images across these 4 applications, instead of duplicating them in each module?

Thanks,

2
  • I think your question is highly opinion based and really depends on your seen and unforeseen requirements as time moves forward. I would suggest having a top level shared resources folder for js, css, img and create a PHP constant of IMAGE_LOCATION, JS_LOCATION, CSS_LOCATION in your index.php or bootstrap.php and protect your directories with a .htaccess file. It will have code duplication instead of file duplication. Commented Feb 24, 2014 at 23:53
  • If you're going to go through all that trouble, you might as well just use one copy of the ZendFramework and change the location of the library instead of 4 copies. Commented Feb 24, 2014 at 23:53

1 Answer 1

1

Two options:

  1. Merge them into one app with 4 modules. Point all 4 domains at the one app, and use hostname routing to load the module relevant to that domain.

  2. Separate the common elements out into a separate module, and then include that as a second module in each application (Composer makes this easy)

The second option would probably be my personal preference, but it depends a lot on the apps and how they are likely to evolve.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.