ghbarratt
ghbarratt

Reputation: 11711

Which PHP frameworks have a code base that can be shared accross entire separate sites easily?

I am looking to reduce redundancies in code shared across entire web sites. I have tinkered with several frameworks but cannot think of any that allow you to EASILY separate the framework code from the site code while sharing it to multiple sites at the same time.

What PHP frameworks can do this easily?

EDIT - I am trying to determine which frameworks are the easiest to share.. I was already guessing that nearly all could be shared, but which frameworks are geared towards sharing? It sounds like Yii recommends placing the framework code outside the site code, that is a good start.

If someone is sharing the same framework code across sites already, I would love to know about that.

Upvotes: 0

Views: 250

Answers (6)

Rodrigo Ferreira
Rodrigo Ferreira

Reputation: 366

It's pretty easy to do that with Fuel (http://fuelphp.com).

Each website has an index.php where some paths are defined:

/**
* Set all the paths here
*/
$app_path       = '../fuel/app/';
$package_path   = '../fuel/packages/';
$core_path      = '../fuel/core/';

As you can see, you may share the core and packages in a central repository and create a single app and public folders to each web site.

You may even share an app with different web sites customizing stuff (let's say, the site title or the database used) by just setting a different environment in the .htaccess. That works out-of-the-box for development/stage/production sites, for example, but may be extended to anything. You may also setup central packages to use in multiple apps. Powerful, easy and just works.

Upvotes: 3

William Durand
William Durand

Reputation: 5519

Symfony2 is suitable for your needs. It's a full stack framework with a lot of standalone components. It works with "bundles", a bundle is a kind of container with a complete logic (controllers, model objects, views, assets, configuration, ...). That means you write one bundle and you can reuse it without any problem.

But you can also consider symfony 1.4. One project can handles many applications so your model is shared across these applications and the same code can be reused in all applications. Note an application can be a complete website.

Upvotes: 1

desbest
desbest

Reputation: 4896

Symfony does. I love the Symfony framework, and it comes with some great frameworks. You might like the Routing and YAML ones. A person I know calls Symfony the best php framework.

Symfony components

Some of the components have their own specific sites

You can find a really good documentation here.

Upvotes: 1

Nanne
Nanne

Reputation: 64399

Many can do this. For instance YII is supposed to be installed OUTSIDE of your www-root directory (httpdocs, /var/www/ or something like that). You can use several sites to point to that base dir.

Any framework (or part) that does not need specific settings for your site can be shared among multiple sites I guess.

Upvotes: 1

Ryre
Ryre

Reputation: 6181

I can't think of any frameworks that do this natively, but you could use several SVN (or hg, etc) repositories to accomplish this. Example using CakePHP:

  • 1 repo has the CakePHP default files. If you wish to update CakePHP, you update this repo in the future.
  • 1 repo per website that stores everything inside your app folder.


It's not built in functionality, but it isn't very difficult to setup either.

Upvotes: 0

Nexerus
Nexerus

Reputation: 1088

I believe Zend can do what you ask, possibly even Symfony and Fuel, and I'm sure many other frameworks that allow you to pick what parts of it to use will let you do this.

However, doing so will require you to do a little more configuring to get it all running. Which is kind of why I ended up creating my own framework.

Upvotes: 1

Related Questions