thedevopser/castor-symfony 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

thedevopser/castor-symfony

Composer 安装命令:

composer require thedevopser/castor-symfony

包简介

Bundle Symfony pour installer le fichier castor.php

README 文档

README

Unit Tests

English version below

Ce bundle fournit un ensemble de tâches Castor pour faciliter le développement et le déploiement d'applications Symfony.

Pré-requis

Ce bundle nécessite l'installation préalable de Castor CLI sur votre système. Pour l'installer, suivez les instructions sur la page d'installation officielle de Castor.

Installation

  1. Installez le bundle via Composer :
composer require thedevopser/castor-symfony
  1. Enregistrez le bundle dans votre application en ajoutant la ligne suivante dans config/bundles.php :
return [
    // ...
    TheDevOpser\CastorBundle\CastorBundle::class => ['all' => true],
];
  1. Installez les fichiers castor.php et castorPersonal.php à la racine de votre projet :
php bin/console castor:install

Note: Lors des mises à jour du bundle, relancez cette commande pour obtenir la dernière version du fichier castor.php. Le fichier castorPersonal.php ne sera pas écrasé.

Personnalisation

Le bundle installe deux fichiers à la racine de votre projet :

  • castor.php : Le fichier principal contenant les tâches prédéfinies
  • castorPersonal.php : Un fichier pour vos tâches personnalisées

Le fichier castorPersonal.php est créé lors de la première installation et n'est jamais écrasé lors des mises à jour du bundle. C'est l'endroit idéal pour ajouter vos propres tâches et personnalisations.

Exemple de personnalisation dans castorPersonal.php :

<?php

use Castor\Attribute\AsTask;
use function Castor\run;

#[AsTask(description: 'Ma tâche personnalisée')]
function maTask(): void
{
    run('echo "Hello from my custom task!"');
}

Tâches disponibles

Installation et Initialisation

  • castor project-init [--node] [--migrate] : Initialise un nouveau projet Symfony
    • Options :
      • --node : Active l'installation des dépendances Node.js
      • --migrate : Execute les migrations après l'initialisation
  • castor install-packages : Installe les dépendances Composer et Node.js
    • Options :
      • --node : Active la prise en charge de Node.Js

Base de données

  • castor create-db : Crée la base de données
  • castor create-migration : Génère une nouvelle migration
  • castor migrate : Exécute les migrations en attente

Qualité de code

  • castor phpstan : Analyse le code avec PHPStan
  • castor phpcsfixer : Vérifie et corrige le formatage PSR-12
  • castor phpcbf : Corrige automatiquement les erreurs de style PSR-12

Gestion Git

  • castor pull-main [--migrate] : Met à jour la branche principale
    • Options :
      • --migrate : Execute les migrations après la mise à jour
  • castor rebase {branch} : Rebase une branche sur main

Docker

  • castor docker-up : Démarre les containers Docker
  • castor docker-down : Arrête les containers Docker

Maintenance

  • castor clean [env] : Nettoie le cache
    • Arguments :
      • env : Environnement cible (défaut: 'dev')

Symfony Castor Bundle

Unit Tests

This bundle provides a set of Castor tasks to facilitate the development and deployment of Symfony applications.

Prerequisites

This bundle requires Castor CLI to be installed on your system. To install it, follow the instructions on the official Castor installation page.

Installation

  1. Install the bundle via Composer:
composer require thedevopser/castor-symfony
  1. Register the bundle in your application by adding the following line in config/bundles.php:
return [
    // ...
    TheDevOpser\CastorBundle\CastorBundle::class => ['all' => true],
];
  1. Install the castor.php and castorPersonal.php files at the root of your project:
php bin/console castor:install

Note: During bundle updates, rerun this command to get the latest version of the castor.php file. The castorPersonal.php file will not be overwritten.

Customization

The bundle installs two files at the root of your project:

  • castor.php: The main file containing predefined tasks
  • castorPersonal.php: A file for your custom tasks

The castorPersonal.php file is created during the first installation and is never overwritten during bundle updates. This is the ideal place to add your own tasks and customizations.

Example of customization in castorPersonal.php:

<?php

use Castor\Attribute\AsTask;
use function Castor\run;

#[AsTask(description: 'My custom task')]
function myTask(): void
{
    run('echo "Hello from my custom task!"');
}

Available Tasks

Installation and Initialization

  • castor project-init [--node] [--migrate]: Initializes a new Symfony project
    • Options:
      • --node: Enables Node.js dependencies installation
      • --migrate: Executes migrations after initialization
  • castor install-packages: Installs Composer and Node.js dependencies

Database

  • castor create-db: Creates the database
  • castor create-migration: Generates a new migration
  • castor migrate: Executes pending migrations

Code Quality

  • castor phpstan: Analyzes code with PHPStan
  • castor phpcsfixer: Checks and fixes PSR-12 formatting
  • castor phpcbf: Automatically fixes PSR-12 style errors

Git Management

  • castor pull-main [--migrate]: Updates the main branch
    • Options:
      • --migrate: Executes migrations after update
  • castor rebase {branch}: Rebases a branch onto main

Docker

  • castor docker-up: Starts Docker containers
  • castor docker-down: Stops Docker containers

Maintenance

  • castor clean [env]: Cleans the cache
    • Arguments:
      • env: Target environment (default: 'dev')

thedevopser/castor-symfony 适用场景与选型建议

thedevopser/castor-symfony 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 353 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 01 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 thedevopser/castor-symfony 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 thedevopser/castor-symfony 我们能提供哪些服务?
定制开发 / 二次开发

基于 thedevopser/castor-symfony 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 353
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-19