afterflow/chisel
Composer 安装命令:
composer require afterflow/chisel
包简介
Work in progress
README 文档
README
Work In Progress. This means that the API may change at any time.
Afterflow Chisel
Chisel is a lightweight, extensible docker compose wrapper written in PHP.
Requirements
Laravel, Docker and docker-compose.
Installation
Grab a fresh installation of Laravel:
laravel new chisel-project
Install Chisel via composer:
composer require afterflow/chisel
Then run:
php artisan chisel:up
Done! You have a Caddy Web server at http://localhost, phpMyAdmin at http://localhost:8080.
MySQL, Queue Worker and Workspace with cron are running on background.
Chisel vs Vessel
Vessel by Chris Fidao is a nice little wrapper around docker-compose. It's written in bash and doesn't require php to be installed on local machine.
Extending behind basic containers is done through editing docker-compose file.
Chisel defines it's services using php classes (still relying on docker-compose under the hood).
In Chisel, the project configuration is defined in docker/docker.php.
You can easily extend or reconfigure services, and now you can also ship some Chisel Service classes with your composer package or reuse them when scaffolding new projects.
Chisel vs Laradock
Laradock is all-in-one all-transparent all-purpose collection of Docker images for Laravel. In fact, Chisel is using some of it's developments but in a slightly opinionated way.
Because of the nature of Laradock's images, build times may be really big and you would need to build and publish intermediate images to make this work with multiple projects/servers. Also, configuring Laradock might get a little overwhelming. Instead, you can build an image with Laradock and then use it with Chisel.
Chisel vs Laravel Valet
Docker on Mac uses slow virtualization and hence, native server software runs faster than dockerized version. Because of this, you might prefer using Valet for the Web stack. Chisel will still be helpful though. For example, you can run Browserless or Redis or Kibana with Chisel and everything else with Valet / native.
Chisel vs Laravel Homestead
Ideally, Chisel should be used over Homestead in all cases. The goal of Chisel is to provide the same level of convenience Homestead provides, but with a production-ready Docker environment and much better extensibility.
Chisel vs docker-compose
Currently, Chisel is using docker-compose under the hood, providing another level of abstraction to make compose configurable with PHP, and hence, extensible through Composer packages.
Using Chisel over Compose just makes scaffolding easier and faster when using on multiple projects on multiple servers, because you can just composer require everything you need without the need to bundle compose files and copy/paste them over and over into new projects.
Basic Usage Examples
Try to migrate the database from your host machine:
php artisan migrate
Same but from inside dockerized workspace
php artisan chisel exec workspace migrate
Notice how it just works with MySQL smoothly out of the box from both host machine and container with a single default .env file.
Compile frontend assets from workspace container:
php artisan chisel:workspace npm install npm run dev
See MySQL logs:
php artisan chisel:logs mysql
Execute arbitrary command on container:
php artisan chisel:exec caddy sh
Execute a shortcut command:
php artisan chisel:exec mysql @dump
Configuration
Run the following command to publish everything:
php artisan chisel:install
This will create a docker directory in the project root.
docker/docker.php
<?php use Afterflow\Chisel\Docker\Services\Caddy\Caddy; use Afterflow\Chisel\Docker\Services\MySQL\MySQL; use Afterflow\Chisel\Docker\Services\PhpFpm\PhpFpm; use Afterflow\Chisel\Docker\Services\PhpMyAdmin\PhpMyAdmin; use Afterflow\Chisel\Docker\Services\Worker\Worker; /* |---------------------------------------------------------------------------- | Docker Networks |---------------------------------------------------------------------------- | | Docker networks are good way to separate access to your services. Each | network has it's own containers. Containers can only "see" other containers | from their own network. You can add container to multiple networks though. | */ Docker::network( 'frontend' ); Docker::network( 'backend' ); /* |---------------------------------------------------------------------------- | Workspace Container |---------------------------------------------------------------------------- | | There is a special "workspace" container stuffed with developer tools like | bash, fish, node, npm, mysql-client and much more, so that you can use all | of them without installing them to your local system. This service is also | responsible for running scheduled tasks. Get a workspace bash shell: | | php artisan chisel:workspace | */ Docker::workspace()->networks( [ 'frontend', 'backend' ] ); /* |---------------------------------------------------------------------------- | Docker Services |---------------------------------------------------------------------------- | | This section describes local, production and common containers of your | application. You can add arbitrary Docker containers or override the | defaults. Use php artisan chisel:publish to tweak these services. | */ // Web Server with automatic HTTPS Docker::service( 'caddy', Caddy::class ); // PHP-FPM backend for the web server Docker::service( 'php-fpm', PhpFpm::class ); // MySQL Database Docker::service( 'mysql', MySQL::class )->networks( [ 'backend' ] ); // MySQL Administration Tool Docker::service( 'phpmyadmin', PhpMyAdmin::class ); // Queue worker service. Docker::service( 'worker', Worker::class )->restart( 'always' ); /* |---------------------------------------------------------------------------- | Pre-Built Chisel Services Collection |---------------------------------------------------------------------------- | | Here you can find a collection of pre-configured drop-in examples for more | Docker services. You can comment them out and everything should work out of | the box. With new versions of Chisel, this section will probably get more | and more examples. Contributions are welcome! | */ // Docker::image( 'browserless', 'browserless/chrome' ) // ->networks( [ 'frontend', 'backend' ] ) // ->ports( [ 3000 => 3000 ] ); /* |---------------------------------------------------------------------------- | Environment Specific Configuration Example |---------------------------------------------------------------------------- | | Here you can define some local-only services like mailtrap, selenium, etc. | or define the same services with different volumes and so on... | */ if ( app()->environment( 'local' ) ) { // Local services } else { // Other services }
Testing
composer test
License
The MIT License (MIT).
afterflow/chisel 适用场景与选型建议
afterflow/chisel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 102 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 02 月 25 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 afterflow/chisel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 afterflow/chisel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 102
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-25