How to create new composer package ?

To make your own composer package, you have to learn about git and svn, we are learning here create package using git.

First you have to create git repo, we are create a git repo, make sure to you have installed git base

git int 

follow some stapes to complete to create composer.json file   after the create composer.json file your composer.json file content has like this

"name": "package name",
"description": "package discription",
"keywords": [],
"type": "package",
"license": "MIT",
"authors": [
"name": "sudeshkumar147",
"email": ""
"require": {
"php": ">=5.6.0"
"require-dev": {
"phpunit/phpunit": "4.0.*"
"autoload": {
"psr-4" : {
"Eriser\\Ecomerce\\" : "src/"
"autoload-dev": {
"psr-4": {
"Eriser\\Tests\\": "tests/"


after the compete process create directory 

directory name "src" and "tests"

under the src create a file name Hello.php

namespace Eriser\Src;
class Hello{
     public function(){
          return "hello";

after the write this you may update composer  to update composer package

 composer update

New your package has been created, test this package

to test this package create a file under tests folder like this

require_once __DIR__.'/../vendor/autoload.php';
$test = new Eriser\Src\Hello;
echo $test->test();

here your test has been complete.

No comments

Powered by Blogger.