Develop Setup Composer - aliconnect/aliconnect.sdk GitHub Wiki

How to use composer

  1. Create folder structure

  2. Create a public repository on GitHub.

  3. Create composer.json at the top level of the repository.

    With composer init you can make a quick template

    {
      "name": "mazraara/random-password",
      "description": "Generate random password of a given length",
      "type": "library",
      "require": {
        "php": ">=5.3.0"
      },
      "license": "proprietary",
      "authors": [
        {
          "name": "Azraar Azward",
          "email": "[email protected]"
        }
      ],
      "minimum-stability": "dev"
    }
    
    1. Write a readme.

      Be sure to include a README for users at least with following,

      • The name of the package
      • How to install
      • How to use
      • License (GitHub function can create LICENSE file)
    2. Write the package code.

      Let’s make an actual package.

      Please note the following points.

      src directory is not mandatory, but it seems that you often put code in a directory

      Write as many tests as possible

      Once ready, add an autoload section to composer.json to allow to use the namespace as RandomPassword\Password

      "autoload": {
        "psr-4": {
          "RandomPassword\\": "src/RandomPassword/"
        }
      }
      
    3. Finally, Register at Packagist (https://packagist.org/)

      Signup using GitHub is easy

      Register the repository at https://packagist.org/packages/submit

      Thats it.

      Now your package should be available at: https://packagist.org/packages/mazraara/random-password

      You can version your package using with git, then users can install with tag specification and it is easy to maintain.

      $ git tag 1.0.0
      $ git push origin 1.0.0
      

      That’s it, you have now contributed to OSS ;-)

    4. Update package

    https://packagist.org/packages/aliconnect/sdk

    Click Update