tech-tips/Языки программирования/PHP/Composer/How to create a PHP package for Composer.md

29 lines
1.4 KiB
Markdown
Raw Permalink Normal View History

It's as easy as 4 steps (minus the part where you code a reusable package in PHP) -- I was surprised too. Make sure before starting you've created a git repository in your project and committed your code. It's also required to have an account on [Github](http://github.com/) and [Packagist](http://packagist/).
1. Create a `composer.json` in your project:
```json
{
"name": "your-brand-name/your-project",
"type": "library",
"description": "Your package description goes here",
"keywords": ["relevant","tags","go","here"],
"homepage": "<https://yourcompany.com>",
"license": "MIT",
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "<http://seld.be>",
"role": "Developer"
}
],
}
```
2. [Create a new repository on your Github](https://github.com/new) and push your local git (init if you haven't) to the remote Github repo.
3. [Submit your package to the Packagist](https://packagist.org/packages/submit)
4. Done! Your package should be online and Packagist should provide a sample Composer require with your project name (e.g. `composer require username/package-name`).
You should be able to view your package live at:
[https://packagist.org/packages/your-username/package-name](https://packagist.org/packages/your-username/package-name)