كيفية إعادة استخدام الكود مع حزم symfony 5؟ الجزء 7. دورة الإصدار والتثبيت والتحديث

دعنا نتحدث عن كيفية إيقاف النسخ واللصق بين المشاريع ونقل الرمز إلى حزمة مكون إضافي قابلة لإعادة الاستخدام Symfony 5. ستنفذ سلسلة من المقالات التي تلخص تجربتي مع الحزم عمليًا من إنشاء حزمة صغيرة وإعادة بناء تطبيق تجريبي إلى الاختبارات ودورة إصدار الحزمة.


في المقالات السابقة من السلسلة ، أخذنا الرمز القابل لإعادة الاستخدام في حزمة كاملة ، وقمنا بتكوينه واختباره. في المقالة الأخيرة ، سنتحدث عن دورة حياة الحزمة: من التثبيت إلى دورة الإصدار.


في هذه المقالة:


  • README.md
  • التثبيت: عبر الملحن ، وصفات المرن ، أوامر وحدة التحكم
  • دورة الإصدار ، إصدار الإصدارات الجديدة
  • النسخ الدلالي
  • إدخال التغييرات على CHANGELOG.md

محتوى المسلسل

إذا لم تكمل البرنامج التعليمي باستمرار ، فقم بتنزيل التطبيق من المستودع وانتقل إلى فرع 6-اختبار .


تعليمات تثبيت وبدء المشروع في ملف README.md. ستجد النسخة النهائية من التعليمات البرمجية لهذه المقالة في فرع الدعم 7 .


تنصل


«»,   ,   . ,  .



, composer:


composer require bravik/calendar-bundle

:


  1. vendors
  2. composer- Symfony Flex, config/bundles.php.

. , - CalendarBundle:


  • - . , config/packages/ - . ?
  • , Doctrine. , , . ?
  • — , . , , . . : composer Symfony , , npm , package.json . .

, ?


README.md


. , : README.md .


, , . .


, . , .


Best Practices for Reusable Bundles


Symfony Flex


Symfony , . , - , ENV-, .gitignore- .


composer Symfony Flex. - , . , , - . .


, . , , , .gitignore, ENV-, .

Symfony Flex? open-source Flex , .


, . : Symfony Contribution- Symfony. Contrib , , .


, . :


Symfony Flex Private Repositories — Fabien Potencier, 2017
Symfony 4 Using Private Recipes with Flex — Sebastian Sellmeier, 2018
Symfony Flex Private Recipes: , — , 2017


, :


  1. 1.5-2
  2. Flex Server , 249 EUR .
  3. Flex Server packagist, .
  4. Flex Server MIT BSD
  5. , . 1.5 .



Symfony Flex Symfony open-source Symfony-, .


CLI- Symfony


, README.md


: .


mybundle/src/Command/InstallCommand.php:


<?php

namespace bravik\CalendarBundle\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Filesystem\Filesystem;

class InstallCommand extends Command
{
    protected static $defaultName = 'bravik:calendar:install';

    /** @var Filesystem */
    private $filesystem;

    private $projectDir;

    public function __construct(Filesystem $filesystem, string $projectDir)
    {
        parent::__construct();

        $this->filesystem = $filesystem;
        $this->projectDir = $projectDir;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $output->writeln('Installing bravik/CalendarBundle...');

        $this->initConfig($output);

        //    
        // ...

        return 0;
    }

    private function initConfig(OutputInterface $output): void
    {
        // Create default config if not exists
        $bundleConfigFilename = $this->projectDir
            . DIRECTORY_SEPARATOR . 'config'
            . DIRECTORY_SEPARATOR . 'packages'
            . DIRECTORY_SEPARATOR . 'calendar.yaml'
        ;
        if ($this->filesystem->exists($bundleConfigFilename)) {
            $output->writeln('Config file already exists');

            return;
        }

        //      
        $config = <<<YAML
calendar:
  enable_soft_delete: true
YAML;
        $this->filesystem->appendToFile($bundleConfigFilename, $config);

        $output->writeln('Config created: "config/packages/calendar.yaml"');

    }
}

, , , .


. , . .


, Symfony, shell-script.



, . , .


, CHANGELOG.md. , :



, , . , , .


:


<major>.<minor>.<patch>

— .


:


  • , , .
  • , , .
  • -, , .


Composer , , - .


CalendarBundle.


?


composer.json:


{
    "name": "bravik/calendar-bundle",
    "version": "0.1.0",
    ...
}

, Composer git-. , . :


git tag v0.1.0

composer.json — composer .


?


composer.json - :


"require": {
    "bravik/calendar-bundle": "^0.1.0",
    ...
},

^ composer , :


  • > 1.0.0 2.0.0.
  •   1.0.0   « », -.

> 0.1.0 < 0.2.0.


?


bundles/CalendarBundle/composer.json :


{
    "version": "0.1.1",
}

:


composer outdated


. — , — . , .


:


{
    "version": "0.2.1",
}


Composer . , . composer , require composer.json -.


?


composer update

.


, Composer


CHANGELOG.md


, , . . . CHANGELOG.md


?


, . , . , — , .


(  «  » 0.X.X) . , . CHANGELOG.md — , . !


CHANGElOG.md, .


:


# CHANGELOG
      

[BC] -   breaking changes

[BugFix] -   

## Unreleased
     
 * CAL-5 [BC]  
 * CAL-5    

## [0.2.0] (2020-04-06)
 * CAL-5 [BC]     
    -       `calendar_bundle.exporter`
 * CAL-6 [BC]     
    -   ,  ,        X  Y.        SQL  "XXX"
 * CAL-7   

## [0.1.1] (2020-03-30)
* CAL-4 [BugFix]      

## [0.1.0] (2020-02-15)
* CAL-1   
* CAL-2   
* CAL-3   
* [BugFix] Editor should initialize blocks only when they change

CHANGELOG.md symfony/framework-bundle. Symfony : . UPGRADE.md Symfony 4 Symfony 5.



Doctrine .


. , . — .


- : - .


SQL , , ?


.


, , .



      ,   .    —  .


7-support.



1.
2.
3. : , , JS
4.
5.
6. ,
7. ,


All Articles