Aylık arşivler: Haziran 2016

Sync your github project with packagist.com package

Packagist Details

Every time you do a new commit to Github you must update the Packagist. Go to your account, your package and click “Force Update!”. Packagist will go to Github and update the sources. You can turn on “auto update” going to your Github repo, clicking “Settings”, after “Service Hooks” and click the “Packagist” service. There update with your information, like:

  • User: your Packagist username, like juniorgrossi
  • Token: your API token, that you can find inside your Packagist settings link
  • Domain: packagist.org Ok! Auto update finished and your package is available to other developers.

Creating own composer package ways

Source: https://knpuniversity.com/screencast/question-answer-day/create-composer-package

  1. way 1
    Add to local project composer.json
    {

    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "username/reponame",
                "version": "dev-master",
                "source": {
                    "url": "git://github.com/username/reponame.git",
                    "type": "git",
                    "reference": "master"
                },
                "autoload": {
                    "psr-0" : {
                        "NameSpace" : "src"
                    }
                }
            }
        }
    ],
    "require": {
        "... other libraries": "... other version",
    
        "username/reponame": "dev-master"
    },
    

    }

  2. way 2
    Add to github library/project composer.json
    {

    {
        "name": "username/reponame",
        "autoload": {
            "psr-0" : {
                "NameSpace" : "src"
            }
        }
    }

    }

    Add to local project composer.json
    {

    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/username/reponame"
        }
    ],

    }

     

  3. way 3
    Register your github library/project to packagist.org (Submit your github url), then use packagist.org username/reponame in your local project composer.json
    {

    "require": {
        "... other libraries": "... other version",
    
        "username/reponame": "dev-master"
    },

    }

Github repo with composer.json and any project uses that repo with composer

GITHUB REPO
hasantktl/fancyrepo
/README
/composer.json
———————-

{
  "name": "hasantktl/fancyrepo",
  "description": "My fancy repo, taste it man!"
}

LOCAL PROJECT FOLDER
C:/poor_project
/READHER (hehe)
/composer.json
—————————–

"require": {
	"hasantktl/fancyrepo": "dev-master" //dev-bugfix2|1.0.2 (branch|tag name)
},
"repositories": [
    {
        "type": "vcs",
    	"url": "https://github.com/hasantktl/fancyrepo"
    }
]

After composer update, in poor_project folder, composer will create vendor path and hasantktl/fancyrepo will be copied to there

Add any GitHub repository to a project using Composer

{
"repositories": {
"yadif": {
"type": "package",
"package": {
"name": "hasantktl/yadif",
"version": "1.0.0",
"source": {
"url": "https://github.com/hasantktl/yadif",
"type": "git",
"reference": "d874042a50"
}
}
}
},
"require": {
"beberlei/yadif": "1.0.0"
},
"autoload": {
"psr-0": {
"Yadif": "vendor/hasantktl/yadif/src/"
}
}
}

We tell Composer how to autoload the classes(“autoload” part) from the package. Because Yadif basically follows the PSR-0 convention, we just tell Composer where the core class files are found, and autoloading is all set up — no need to mess with symlinks or include paths.