哪些 PHP 框架具有可以在整个单独站点之间轻松共享的代码库?

发布于 2024-12-09 16:04:26 字数 232 浏览 0 评论 0原文

我希望减少整个网站共享的代码冗余。我已经修改了几个框架,但想不出任何框架可以让您轻松地将框架代码与站点代码分开,同时将其共享到多个站点。

哪些 PHP 框架可以轻松做到这一点?

编辑 - 我正在尝试确定哪些框架最容易共享。我已经猜测几乎所有框架都可以共享,但是哪些框架适合共享?听起来 Yii 建议将框架代码放在站点代码之外,这是一个好的开始。

如果有人已经跨站点共享相同的框架代码,我很想知道这一点。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

清欢 2024-12-16 16:04:26

使用 Fuel (http://fuelphp.com) 可以很容易地做到这一点。

每个网站都有一个index.php,其中定义了一些路径:

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

如您所见,您可以在中央存储库中共享核心和包,并为每个网站创建单个应用程序和公共文件夹。

您甚至可以与不同的网站共享一个应用程序,通过在 .htaccess 中设置不同的环境来自定义内容(例如,网站标题或使用的数据库)。例如,这对于开发/阶段/生产站点来说是开箱即用的,但可以扩展到任何东西。您还可以设置中央包以在多个应用程序中使用。功能强大、简单且有效。

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.

污味仙女 2024-12-16 16:04:26

许多人都可以做到这一点。例如,YII 应该安装在 www 根目录之外(httpdocs/var/www/ 或类似的目录)。您可以使用多个站点来指向该基本目录。

我猜,任何不需要为您的站点进行特定设置的框架(或部分)都可以在多个站点之间共享。

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.

难如初 2024-12-16 16:04:26

我相信 Zend 可以满足您的要求,甚至可能是 Symfony 和 Fuel,而且我相信许多其他允许您选择要使用的部分的框架也可以让您做到这一点。

但是,这样做将需要您进行更多配置才能使其全部运行。这就是我最终创建自己的框架的原因。

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.

过气美图社 2024-12-16 16:04:26

Symfony 确实如此。我喜欢 Symfony 框架,它附带了一些很棒的框架。您可能喜欢路由和 YAML。我认识的一个人称 Symfony 是最好的 php 框架。

Symfony 组件

一些组件有自己的特定站点

您可以找到一个非常好的文档在这里。

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.

琴流音 2024-12-16 16:04:26

Symfony2 适合您的需求。它是一个包含许多独立组件的全栈框架。它与“bundles”一起工作,bundles是一种具有完整逻辑(控制器、模型对象、视图、资产、配置...)的容器。这意味着您编写了一个捆绑包,并且可以毫无问题地重复使用它。

但你也可以考虑 symfony 1.4。一个项目可以处理许多应用程序,因此您的模型可以在这些应用程序之间共享,并且可以在所有应用程序中重用相同的代码。请注意,应用程序可以是一个完整的网站。

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.

因为看清所以看轻 2024-12-16 16:04:26

我想不出任何框架可以本地执行此操作,但您可以使用多个 SVN(或 hg 等)存储库来完成此操作。使用 CakePHP 的示例:

  • 1 个存储库具有 CakePHP 默认文件。如果您想更新 CakePHP,
    您将来更新此存储库。
  • 每个网站 1 个存储库,用于存储应用程序文件夹中的所有内容。

它不是内置功能,但设置也不是很困难。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文