Develop Paper
  • Program
  • Server
  • Development Tool
  • Blockchain
  • Database
  • Artificial Intelligence
Position: Home > Program > Content

Composer package development

Time:2020-2-25

Introducer

I don’t need to introduce the composer management package too much. I think you all know it. Some time ago, I published the composer package to the intranet hosting platform. Today, I have time to try to publish it to packagist and sort out the records.

Preparation

The preparation is very simple. There are two points in total

  1. Create a new project in GitHub to manage the code of the composer package
  2. Register an account with packagist and use GitHub account

Development

Make a simple demo

  1. Clone the project in GitHub to local
  2. implementcomposer initCommand to initialize. If there are other dependencies, you can configurerequireandrequire-devparameterComposer package development
  3. It will be created after the previous stepcomposer.jsonThe document can also be modified directly if it needs to be modifiedcomposer.json
  4. Next, write a simple function to createsrc/helpers.php, the code is as follows
<?php

function init()
{
    echo 'test composer';
}
  1. Finally, we need tocomposer.jsonThe loading method is defined in. For the loading mechanism, see this article. Because demo is relatively simple, usefilesThat’s it, eventuallycomposer.jsonas follows
{  
    "name": "test/test-composer",  
    "description": "test",  
    "type": "library",  
    "require": {  
        "php": "^7.2"  
  },  
    "license": "MIT",  
    "authors": [  
        {  
            "name": "test",  
            "email": "[email protected]"  
  }  
    ],  
    "autoload": {  
        "files": [  
            "src/helpers.php"  
  ]  
    }  
}

Release

  1. Don’t forget the version numbergit tag v1.0.0
  2. Push code to GitHub and tag to pushgit push origin --tags
  3. Click submit on packagist platform, fill in the address of GitHub project, and click Check
  4. You can use it latercomposer requireInstall the package just released
  5. Packagist will update automatically when the code is submitted to GitHub later. If there is no update, please refer to this article for configuration

epilogue

It’s a very simple demo, and it doesn’t writephpunit, mainly to be familiar with the next process It is very important.


Reference: composer package development is so simple. Learn to develop your own composer package. Use GitHub to update to packagist in real time, and learn about composer autoload mechanism in depth.

Tags: Account number, Article, code, project, version number

Recommended Today

Interviewer: young man, what do you think of the principle of distributed system

1 Concept 1.1 model 1.2 copies 1.3 indicators for measuring distributed systems 2. Principle of distributed system 2.1 data distribution 2.2 basic copy agreement 2.3 lease mechanism 2.4 quorum mechanism 2.5 log technology 2.6 two phase submission protocol 2.7 MVCC 2.8 Paxos protocol 2.9 CAP 1 Concept 1.1 model node In a specific project, a […]

  • Interpretation of laravel kernel — HTTP kernel
  • Angularjs instruction practice
  • Floating and sinking of technological sea in cloud based system and theoretical exploration
  • Brief introduction of react and Redux integration technology
  • Understand promise through callback
  • Look at animation algorithm: sort insert sort
  • Using mixphp to create multi process asynchronous mail sending
  • What’s the difference between web and API when standard fun develops API interface in PHP?
  • Spring MVC will know that you won’t ask to hack me
  • Details neglected in NPM dependency management
Pre: Understand dart asynchrony thoroughly
Next: Fight 24 hours, Hangzhou future science and technology city enterprise return to work record platform online!

    Tags

    address algorithm android array assembly attribute Browser c Catalog Character string Client code command configuration file css data Database data base Edition element Example file function golang html html5 ios java javascript linux method mysql node node.js object page parameter php Plug-in unit project python Route source code The server user

    Recent Posts

    • Interviewer: young man, what do you think of the principle of distributed system
    • What can we learn from HelloWorld
    • Centos7 reset root password (detailed version)
    • Windows 10 uses screen keyboard
    • Interpretation of laravel kernel — HTTP kernel

    Recent Comments

    • Li VST on Answer for Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Li VST on Answer for Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Li VST on Answer for Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Li VST on Didi travel app home page selection address can be pushed to the top of the effect how to do?
    • Healy on Answer for Is the main thread of browser JS engine thread?

    Categories

    • .NET Core
    • Agile Development
    • Android
    • Apple MAC
    • Architecture Design
    • Artificial Intelligence
    • ASP.NET
    • Blockchain
    • C
    • C#
    • C++
    • Database
    • Development Tool
    • Embedded
    • Erlang
    • Freshman
    • Golang
    • HTML/CSS
    • HTML5
    • Information Security
    • IOS
    • Java
    • JavaScript
    • JSP
    • Linux
    • MongoDB
    • MsSql
    • MySql
    • OOP
    • oracle
    • Other DB
    • Other Technology
    • Perl
    • PHP
    • Program
    • Python
    • Redis
    • Regular Expression
    • Ruby
    • Rust
    • SAP
    • Server
    • VBS
    • VUE
    • WEB Front End
    • Windows
    • XML/XSLT
  • java
  • php
  • python
  • linux
  • windows
  • android
  • ios
  • mysql
  • html
  • .net
  • github
  • node.js

Copyright © 2020 Develop Paper All Rights Reserved   

  Sitemap    About DevelopPaper    Privacy Policy    Contact Us