strictphp/conventions
Composer 安装命令:
composer require strictphp/conventions
包简介
Our code conventions forced by PHPStan, Easy Coding Standard, RectorPHP and appropriate custom rules and configs.
README 文档
README
Welcome to StrictPHP Conventions, a Composer package designed to standardize PHP code across various our projects. This package is an assembly of tools and configurations to enhance code quality, maintainability, and adherence to best practices. It's crafted with care for developers seeking consistency and excellence in their projects, and we encourage its adoption. Pull Requests are welcome!
Features Included
This package bundles a selection of powerful tools and configurations to support your development workflow:
- PHPStan Configuration and Custom Rules: Integrates PHPStan, with pre-defined configurations and rules tailored for our projects.
- Easy Coding Standard Configuration: Utilizes Easy Coding Standard for enforcing consistent coding styles and practices.
- PHPUnit 10/11 Support: Ensures compatibility with PHPUnit to facilitate comprehensive testing.
- RectorPHP Configuration: Provides configurations for RectorPHP for better code quality.
- Extended PHPStan Packages: Includes additional packages to augment PHPStan's capabilities. For more details, see
the included
composer.jsonfile.
For Laravel use LaraStrict conventions.
Prerequisites
Before installing, please ensure your environment meets the following requirements:
- PHP version 8.1 or higher.
- Composer
- Enabled Extension installer for PHPStan - it is installed by our package to allow extension discovery.
Only the latest major version of this package is maintained.
| Version | PHPUnit | PHP |
|---|---|---|
| 2.x | 10/11/13 | 8.3+ |
| 1.x | 10/11 | 8.1+ |
| 0.x | 9 | 8.1+ |
Installation
To incorporate StrictPHP Conventions into your project, simply run the following command in your terminal:
composer require strictphp/conventions --dev
This will install the package as a development dependency. You will be asked to confirm the installation of the plugin:
Do you trust "phpstan/extension-installer" to execute code and wish to enable it now? (yes/no) [y]:
Type y to use all the extensions provided by the package.
Getting Started
After installation, you can extend the provided configurations to suit your project's specific needs.
Setting Up Easy Coding Standard
To use the Easy Coding Standard, create an ecs.php file at your project's root with this setup or update your
configuration:
<?php declare(strict_types=1); use Symplify\EasyCodingStandard\Config\ECSConfig; return ECSConfig::configure() ->withRootFiles() ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', ]) // This is required to include the StrictPHP Conventions ->withSets([\StrictPhp\Conventions\ExtensionFiles::Ecs]);
Configuring RectorPHP
For integrating RectorPHP, add a rector.php file in your project's root with the following configuration or update
your configuration :
<?php declare(strict_types=1); use Rector\Config\RectorConfig; return RectorConfig::configure() ->withRootFiles() ->withPaths([ __DIR__ . '/src', __DIR__ . '/tests', ]) // This is required to include the StrictPHP Conventions ->withSets([\StrictPhp\Conventions\ExtensionFiles::Rector]);
Integrating PHPStan
It is required you to use phpstan extension installer to install the required extensions. This is recommended setup:
parameters: level: max paths: - src - ecs.php - rector.php - extension-ecs.php - extension-rector.php
Acknowledgement
This project owes its existence to the generous support of several other impactful projects:
- Canvastera - Empowering users to craft multimedia posters and share them worldwide. ( EDU/Hobby)
- Azzurro Travel Agency - Specializing in holidays in Italy.
- Redtag Studio - Crafting digital products for your enjoyment.
Explore more of our open-source initiatives:
- Larastrict - Enhancing the Laravel Framework with a suite of convenient tools and packages.
- StrictPHP - Enabling strictness in PHP projects through a curated set of packages and conventions, fostering the development of robust production-grade applications.
- WrkFlow - Streamlining development workflows with a comprehensive set of tools designed to boost efficiency.
License
Open-source software licensed under the MIT License. Feel free to use and modify it according to your needs.
strictphp/conventions 适用场景与选型建议
strictphp/conventions 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 868 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 04 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 strictphp/conventions 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 strictphp/conventions 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 868
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 15
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-06
