Create package and release to packagist with composer and github

0
1173
views

In this section, we will create a PHP package in GitHub and release it into packagist.org.

  1. Create a new folder, which is the name will become your package name. Example calculator.
  2. Create a new folder inside calculator, with name src. Your file should be stored /li>
  3. Create file Calculator.php with class Calculator, like below

     
  4. Create composer.json in your top folder (calculator/composer.json)
  5. With composer init or manually like below

    The important things, your namespace (redzjovi\calculator) in folder src should be autoloaded.
  6. Run composer update. Then create folder test and file test.php to test the class.
  7. After test complete, create README.md, commit and push to your GitHub.

  8. The url git should be located inĀ https://github.com/redzjovi/calculator.git.
  9. Go to packagist.org, create account and try to submit package.
  10. If your package is accepted, it will be show like this.
  11. The last is set auto update package on every push with Webhooks GitHub. Go to settings -> integration & services, add services packagist.Add user, token from packagist, then submit.

Reference :
https://github.com/redzjovi/calculator

LEAVE A REPLY

Please enter your name here
Please enter your comment!