{"id":19854712,"url":"https://github.com/phwoolcon/bootstrap","last_synced_at":"2025-09-20T21:25:40.612Z","repository":{"id":57041234,"uuid":"56962468","full_name":"phwoolcon/bootstrap","owner":"phwoolcon","description":"Phwoolcon Framework","archived":false,"fork":false,"pushed_at":"2019-07-31T04:51:57.000Z","size":1340,"stargazers_count":29,"open_issues_count":0,"forks_count":17,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-06T20:35:48.570Z","etag":null,"topics":["modularization","phalcon","swoole"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/phwoolcon.png","metadata":{"files":{"readme":"README-zh.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-24T08:46:18.000Z","updated_at":"2022-03-10T23:25:20.000Z","dependencies_parsed_at":"2022-08-24T01:10:54.896Z","dependency_job_id":null,"html_url":"https://github.com/phwoolcon/bootstrap","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fbootstrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fbootstrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fbootstrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phwoolcon%2Fbootstrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phwoolcon","download_url":"https://codeload.github.com/phwoolcon/bootstrap/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251969247,"owners_count":21673182,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["modularization","phalcon","swoole"],"created_at":"2024-11-12T14:10:12.458Z","updated_at":"2025-09-20T21:25:35.560Z","avatar_url":"https://github.com/phwoolcon.png","language":"PHP","readme":"# Phwoolcon Bootstrap\n\nPhalcon + Swoole\n\n[Demo](https://phwoolcon.org/)\n\n***\n\nBootstrap 用于提供 Phwoolcon 运行时的目录结构。\n\n本项目的目的是创建一个高性能的 Web 应用程序，既可以运行于传统的 php-fpm\n模式下，也可以运行在服务模式下。\n\n在服务模式中，你的应用程序可以减少许多非必要的重复计算，获得极致的性能。\n\n如果在服务模式中出现了 Bug，你可以轻松地关闭服务模式，损失一些性能\n（但是仍然很快）换取稳定性，待 Bug 修复后再启用服务模式。\n\n# 1. 系统要求\n* Linux 或者 MacOS（不推荐 Windows，也没测试过。\n不过你可以在 Windows 上用 VirtualBox 之类的虚拟机安装 Linux）\n* Nginx（推荐最新版本）\n* PHP version \u003e= 5.5（推荐 7.1，2017 年注）\n* PHP 组件: fpm, gd, cli, curl, dev, json, mbstring, pdo-mysql, redis, xml, zip\n* MySQL server (或者 MariaDB / Percona / TiDB)\n* Phalcon（推荐最新版本）\n* Swoole（推荐最新版本）\n* Composer（推荐最新版本）\n\n# 2. 使用\n## 2.1. 创建工作目录\n```bash\ngit clone git@github.com:phwoolcon/bootstrap.git my-project-name\ncd my-project-name\n```\n\n\u003ca name=\"s2.2\"\u003e\u003c/a\u003e\n## 2.2. 导入 Composer 包\n请 **不要** 直接编辑 `composer.json`，这样会使你无法获取架的更新。\n\n请使用 `bin/import-package` 创建 `composer.local-*.json` 来导入依赖。\n`composer.local-*.json` 与框架是隔离的。\n\n例如：\n\n* 导入一个公开的 composer 包：\n```bash\nbin/import-package some/public-package\n```\n\n* 导入一个私有的 composer 包：\n```bash\nbin/import-package git@git.example.com:my/private-project.git\n```\n\n关于 `composer.local-*.json` 的更多详情请查看 [Composer Merge Plugin (by Wikimedia)](https://github.com/wikimedia/composer-merge-plugin/blob/master/README.md#plugin-configuration)。\n\nDemo: [Phwoolcon Demo](https://github.com/phwoolcon/demo#7-install-phwoolcondemo).\n\n## 2.3. 组织你的项目代码\n把所有项目代码都用 `composer 包` 来组织。\n\n**绝对不要** 把你的代码放进 `app/` 目录里面，这样非常难以实施模块化。\n\n\u003ca name=\"s2.3.1\"\u003e\u003c/a\u003e\n### 2.3.1 创建一个 Phwoolcon 包\n运行：\n```bash\nbin/cli package:create\n```\n这个工具会问你填一些基本信息，像这样：\n\n```text\n----------------------------------------------------------------------\nPlease, provide the following information:\n----------------------------------------------------------------------\nYour name: Christopher CHEN\nYour Github username (\u003cusername\u003e in https://github.com/username): Fishdrowned\nYour email address: fishdrowned@gmail.com\nYour website [https://github.com/Fishdrowned]:\nPackage vendor (\u003cvendor\u003e in https://github.com/vendor/package) [Fishdrowned]: phwoolcon\nPackage name (\u003cpackage\u003e in https://github.com/vendor/package): theme-mdl\nPackage very short description: The Material Design Lite Theme for Phwoolcon\nPSR-4 namespace (usually, Vendor\\Package) [Phwoolcon\\ThemeMdl]: \n\n----------------------------------------------------------------------\nPlease, check that everything is correct:\n----------------------------------------------------------------------\nYour name: Christopher CHEN\nYour Github username: Fishdrowned\nYour email address: fishdrowned@gmail.com\nYour website: https://github.com/phwoolcon\nPackage vendor: phwoolcon\nPackage name: theme-mdl\nPackage very short description: The Material Design Lite\nPSR-4 namespace: Phwoolcon\\ThemeMdl\n\nModify files with these values? [y/N/q] y\n\nDone.\nNow you should remove the file 'prefill.php'.\n\n----------------------------------------------------------------------\nPlease, provide the following information:\n----------------------------------------------------------------------\nGit repository (The git repository of the package) [git@github.com:phwoolcon/theme-mdl.git]: \nChoose license (1 - APACHE 2.0, 2 - MIT, 3 - Proprietary) [1]: \n```\n\n然后你在 `vendor` 目录下可以找到一个新包，并且已经添加了  \ngit 远程仓库，就等你 commit 和 push 了。\n\n```bash\ngit commit -m \"Initial commit\"\ngit push\n```\n\n现在你拥有了一个私有的 composer 仓库，你的第一个 `Phwoolcon 包`。\n\n如果你乐于分享，你可以把它发布到 [GitHub](https://github.com) 和 [Packagist](https://packagist.org) 上。\n\n### 2.3.2. 导入你的项目\n现在你可以把刚才创建的 Phwoolcon 包导入进来了。\n\n参阅 [2.2. 导入 Composer 包](#s2.2)\n\n### 2.3.3. 更新代码\n```bash\nbin/update\n```\n这个脚本会做以下工作：\n\n* `git pull` 更新框架 (`phwoolcon/bootstrap`) 本身；\n* `composer update` 更新所有 composer 包，包括你的项目；\n* `bin/cli migrate:up` 运行数据库更新脚本；\n* `bin/dump-autoload` 更新 composer autoload，应用最新的  \nassets，配置文件，翻译文件，生成 model trait 和 IDE helper。\n\n## 2.4. Phwoolcon 配置文件\n项目配置文件是用 symlink 从各个 `Phwoolcon 包` 里面连接 `app/config` 目录里的。\n\n请 **不要** 直接编辑 `app/config` 目录下的文件。\n\n### 2.4.1. 应用环境配置\n复制配置文件到 `app/config/{$environment}/` 里面以覆盖默认配置。\n\n`{$environment}` 是运行时环境的名称，默认为 `production`。\n\n你可以通过 `$_SERVER['PHWOOLCON_ENV']` 改变这个名称。\n\n### 2.4.2. 增加自己的配置文件\n回到你的项目包（`vendor/my/project`），你可以在子目录\n`phwoolcon-package/config/` 下面创建新的配置文件。\n\n然后运行 `bin/dump-autoload` 把他们连接到 `app/config`.\n\n在你的代码里面可以使用这些配置项，举个例子：\n\n配置文件 `phwoolcon-package/config/key.php`\n```php\n\u003c?php\nreturn [\n    'to' =\u003e [\n        'config' =\u003e 'hello',\n    ],\n];\n```\n\n在你的代码里面：\n\n```php\necho Config::get('key.to.config'); // 输出 \"hello\"\n```\n\n**重要** 请 **不要** 创建重名的配置文件（例如默认的 `app.php`）。\n\n## 2.5. 模块化\n代码复用，模块化，都是这么讲，可是真正实施起来还是有难度的，\n你是不是把“模块”在不同项目之间复制来复制去？\n\nPhwoolcon 这样解决：\n\n* 首先把项目本身做成一个 `Phwoolcon 包`；\n* 接下来把你各个项目里面的公用组件也都做成 `Phwoolcon 包`；\n* 然后把它们加到项目包的 `composer.json` 里面。\n\n**重要** 所有私有仓库都 **必须** 在 `composer.local.json` 文件（参见步骤 [2.3.1 创建一个 Phwoolcon 包](#s2.3.1)）的\n`repositories` 中声明，否则 `composer` 找不到它们。\n\n## 2.6. 构建 / 部署\n部署 composer 项目是一件痛苦的事情，因为：\n\n* 如果你依赖 `composer update`，你可能部署了不一致的代码；\n* 如果你把 `vendor` 放进版本控制系统，在开发过程中要么和\ncomposer 冲突，要么干脆放弃更新；\n* `composer update` 真他妈慢，而且可能会失败。\n\nPhwoolcon 解决部署问题的方法是，把工作目录打包，然后放进 `release` 分支。\n\n### 2.6.1. 构建\n```bash\nbin/build\n```\n\nbuild 脚本会在工作目录下创建一个 `ignore/release` 目录，\n这个目录里的内容是可以直接推到生产环境上的。\n\n把这个目录加入你的项目仓库，放到 `release` 分支下。\n\n### 2.6.2. 部署\n#### 2.6.2.1. 手动部署\n\n让我们用 `rsync` 作例子：\n```bash\nrsync -auv --delete --chown=www-data:www-data --rsync-path='sudo rsync' \\\n    --exclude-from=./deployignore ./ \\\n    user@production-host:/path/to/production/directory/\nssh www-data@production-host \\\n    '/path/to/production/directory/bin/dump-autoload'\n```\n\n#### 2.6.2.2. 自动部署\n请见 [Deploy Automator](https://github.com/phwoolcon/deploy-automator)\n\n## 2.7. 服务模式\n\n### 2.7.1. 启用服务模式\n要启用服务模式，请在 CGI 参数中设置 `USE_SERVICE` 为 1。\n```conf\n    location ~ \\.php$ {\n        .\n        .\n        .\n        fastcgi_param USE_SERVICE 1;\n    }\n```\n\n### 2.7.2. 启动/停止服务\n启动服务请运行：\n```bash\nbin/cli service start\n```\n现在 phwoolcon 服务将处理你的网站请求。\n\n停止服务请运行：\n```bash\nbin/cli service stop\n```\n现在你的网站仍然在 php-fpm 模式下可用。\n\n### 2.7.3. 安装为系统服务（未完成）\n运行这个命令把你的网站安装为一个系统服务：\n```bash\nbin/cli service install\n```\n然后你可以 start/stop/restart/reload 你的服务：\n```bash\nservice phwoolcon start\nservice phwoolcon stop\nservice phwoolcon restart\nservice phwoolcon reload\n```\n卸载系统服务：\n```bash\nbin/cli service uninstall\n```\n\n# 3. 主旨\n* 关注性能\n    * 这就是为什么用 Phalcon 和 Swoole\n* 关注伸缩性\n    * 构建跨机房分布式系统的潜力（还在开发中）\n* 提供强大的功能，但是保持直观易读的代码\n    * Keep it simple and do it right\n* 模块化实施\n    * 再也不在 `app/` 里写代码，用 composer 包代替\n* 部署友好\n    * 再也不用在生产环境上面跑 `composer update`\n\n# 4. 功能\n\n## 4.1. 基础组件\n* Extended Phalcon Config (Both in native PHP file and DB)\n* Phalcon Cache\n* Extended Phalcon ORM\n* View: Theme based layouts and templates\n* Multiple DB connector\n* Events\n* Configurable Cookies\n* Session\n* Openssl based encryption/decryption\n* Multiple Queue producer and asynchronous CLI worker\n* Assets: Theme based, compilable JS/CSS management\n* Log\n* Lighten route dispatcher\n* Internalization\n* Finite state machine\n* Mail\n* Symfony CLI console\n\n## 4.2. 特定组件\n* Admin interface\n* User authentication (Register and login)\n* SSO Server and client\n* Orders\n* Payment\n\n## 5. 致谢\nPhwoolcon Bootstrap 使用了第三方库和其他资源，它们可能采用了与 Phwoolcon  \n不同的许可证进行发布，详情请见 [Credits](CREDITS.md)。\n\n## 6. 许可证\nPhwoolcon Bootstrap 采用 [Apache License 2.0](LICENSE.md) 进行许可\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphwoolcon%2Fbootstrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphwoolcon%2Fbootstrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphwoolcon%2Fbootstrap/lists"}