search
HomeDevelopment ToolscomposerIntroducing the PR process record of a composer package

下面由composer教程栏目带大家介绍pr一个composer包过程记录 ,希望对需要的朋友有所帮助!

Introducing the PR process record of a composer package

看到一位朋友的 enum包,感觉还不错。

因为在实际开发中 我们使用  BenSampo/laravel-enum(https://github.com/BenSampo/laravel-enum)这个包去管理枚举。

在标准化项目中(比如国际化)其实这个包挺好的。但是在小项目中,先添加枚举类,再去enums.php 中添加翻译,让人感觉很繁琐

像这样子:
Introducing the PR process record of a composer package
所以对这个注解读取“翻译”的这个包,我很感兴趣。

但是问题来了,这个包里面只能读取枚举翻译,如果我需要一个数组呢?

像这样:

AppStatus::toSelectArray()

我想用这个包,但是我又想用到toArray,我满足这两个条件,我在小项目中就可以操刀就干,而又不失优雅。

所以,我决定fork一份自己改一下,添加toArray 的方法

fork好了之后,在项目根目录中添加 一个 packages的文件夹,在这个文件夹中,git clone github.com/liaoshengping/x-phalcon...

composer.json 中添加,本地目录

    "repositories": [
        {
            "type": "path",
            "url": "packages\\x-phalcon-enum"
        }
    ]

接下来

composer require limingxinleo/x-phalcon-enum dev-master

在vendor 会生成一份 和packages 一样的 文件。这时已经映射到了 packages ,只需要修改其中的文件就可以了。

在  Enum.php 添加一个toArray 的静态方法。

    public static function toArray(){
        $ref = new ReflectionClass(static::class);
        $properties = $ref->getDefaultProperties();
        $_adapter = new ReflectionAdapter(static::class);
        $arr = $_adapter->getAnnotationsByName('Message', $properties);
        return $arr;
    }

push 到 自己的master 上,创建一个 Pull Request,如图:

Introducing the PR process record of a composer package

等大佬检查代码,如果通过则合并。

这样就完成了我第一个pr
Introducing the PR process record of a composer package                                                          

The above is the detailed content of Introducing the PR process record of a composer package. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:learnku. If there is any infringement, please contact admin@php.cn delete
Composer and AI: Exploring the IntersectionComposer and AI: Exploring the IntersectionApr 17, 2025 am 12:15 AM

The combination of Composer and AI can help composers create novel musical works. AI generates new clips by analyzing music data that composers can use as inspiration or directly integrate. Challenges include ensuring the emotional depth of the music and the balance of human-computer creation.

Composer: Streamlining PHP Project DevelopmentComposer: Streamlining PHP Project DevelopmentApr 15, 2025 am 12:08 AM

Composer simplifies PHP project development steps include: 1) adding dependencies, such as adding "laravel/framework":"^8.0" in composer.json; 2) automatically loading, generating an autoload.php file by defining the namespace and classpath; 3) optimizing performance, using composerdump-autoload-o and composerinstall--no-dev-optimize-autoloader commands. Through these steps, developers can be more efficient and avoid common mistakes.

Composer Credentials: What Makes Someone a Composer?Composer Credentials: What Makes Someone a Composer?Apr 14, 2025 am 12:13 AM

The key elements of becoming a composer include: 1. Mastering music theory, 2. Being creative and original, 3. Having technical skills, 4. Being able to express emotions and tell stories, 5. Understand cultural and historical background, 6. Accumulating practice and experience, these elements together constitute the composer's identity and ability.

The Path to Becoming a Composer: A Practical GuideThe Path to Becoming a Composer: A Practical GuideApr 13, 2025 am 12:11 AM

The steps to becoming a composer include: 1. Master the basic elements of music, such as notes, rhythm, harmony, and melody; 2. Select appropriate technical tools, such as AbletonLive; 3. Understand the process of composing, including inspiration acquisition, conception, writing, modification and improvement; 4. Start with simple melody creation and gradually try complex techniques such as harmony; 5. Solve common problems through debugging techniques, such as note selection and rhythm arrangement; 6. Apply performance optimization and best practices, such as using templates, version control, and collaboration.

Composer: The Key to Building Robust PHP ApplicationsComposer: The Key to Building Robust PHP ApplicationsApr 12, 2025 am 12:05 AM

Composer is a key tool for building robust PHP applications because it simplifies dependency management, improves development efficiency and code quality. 1) Composer defines project dependencies through composer.json file and automatically downloads and manages these dependencies. 2) It generates a composer.lock file to ensure that the dependency version is consistent and automatically loaded through vendor/autoload.php. 3) Examples of usage include basic usage such as adding log libraries, as well as advanced usage such as version constraints and environment variable management. 4) Common error debugging techniques include handling dependency conflicts and network problems. 5) Performance optimization suggestions include using composer.lock file and optimizing automatic loading.

Composer Expertise: What Makes Someone SkilledComposer Expertise: What Makes Someone SkilledApr 11, 2025 pm 12:41 PM

To become proficient when using Composer, you need to master the following skills: 1. Proficient in using composer.json and composer.lock files, 2. Understand how Composer works, 3. Master Composer's command line tools, 4. Understand basic and advanced usage, 5. Familiar with common errors and debugging techniques, 6. Optimize usage and follow best practices.

What is a composer doing?What is a composer doing?Apr 08, 2025 am 12:19 AM

Composer is a dependency management tool for PHP, used to declare, download and manage project dependencies. 1) Declare dependencies through composer.json file, 2) Install dependencies using composerinstall command, 3) parse the dependency tree and download it from Packagist, 4) generate the autoload.php file to simplify automatic loading, 5) optimize use includes using composerupdate--prefer-dist and adjusting the autoload configuration.

What is App composer?What is App composer?Apr 07, 2025 am 12:07 AM

AppComposer is a tool for building and managing applications. 1) It simplifies application development and improves efficiency by dragging and configuring predefined components. 2) Developers can define components, combine interfaces, define business logic, and ultimately render the application. 3) Support basic and advanced usage, such as task management and conditional rendering, helping to build flexible applications.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools