But I still can't get myself started. Is Satis is installed by project based? If so, would that mean I have to install Satis on every new project?
No, satis is your personal packagist-like repository. Inside of it, you keep a set of definitions for where to get the packages that you want to host yourselves, instead of getting them from packagist.
I tried to run composer.phar create-project composer/satis --stability=dev from a folder and I get error message saying that composer.phar is not found.
The command would have been php 'composer.phar' in case composer were not in your path (https://getcomposer.org/doc/00-intro.md#globally)
So, I try with composer create-project composer/satis --stability=dev and it create a new folder called satis inside the folder I run composer.
Good, it means you have moved composer.phar to /usr/local/bin/composer and you can run it globally (meaning that you can run it from every directory in your system) by just running "composer"
A "logical" step by step instruction about how to run satis should clarify what I think is confusing you:
Background
You want to have satis because you want to serve some projects from your own repository (git or other, I'll make my example with git) instead of pulling it from the repo that is defined inside the service used as default by composer, i.e. packagist. Probably you want to make changes to the original package and don't want to have them overwritten when there are updates to the package. Hence you need an intermediate step were you can merge your changes with the upstream changes.
Brief Composer Work Flow
Packagist does not hold the source code of the packages, it holds a set of definitions for each package (the composer.json file), and among this set, a definition for which repo the package is available from.
When you run composer,
- it reads the definitions in packagist
- it downloads the package from the defined public repo (github, git, svn etc)
- it compiles it following other definitions found in the package itself
Brief Composer/Satis workflow
With satis the flow is:
- Composer is instructed to use the definitions within satis
- it reads the definitions found in satis
- it downloads the package from the public repo that is defined in satis
- it compiles it following other definitions found in the package itself
Step By Step Creating a Useful Composer/Satis/Git Setup
Following from the above, a step by step instruction is:
- install composer globally (for simplicity, and you have it already)
- in a folder that will become available from the web, install satis
- somewhere in your system (easiest in a home location of a dedicated git user, it might be the 'satis' user), clone a git repo for a package that you want to modify and serve from your own git repo
- Add a satis.json file inside your satis repo with definitions for your project
- From the same location run 'php bin/satis build satis.json root/ (I prefer 'root/' instead of the standard 'web/') and set the documentRoot of your webserver to 'path/to/root/'
For step #4 above, eg.:
{
"name": "My Repo",
"homepage": "http://satis.mydomain.com",
"repositories": [
{
"type": "git",
"url": "[email protected]:<packagename>"
}
],
"require-all": true
}
Now you have: composer, a git repo and a satis repo (your own packagist). All those are in different and independent locations.
Step By Step Using Satis and Git from Composer
Make a directory where you want to install the package
As by composer instructions, add in this directory a composer.json file. This time though the package is your modified version, so the composer.json file will for instance look like this:
{
"name": "<yourname>/<packagename>",
"repositories": [
{
"type": "composer",
"url": "http://satis.yourdomain.com"
},
{"packagist": true},
{ "type": "composer", "url": "https://packagist.org" }
],
"version": "dev-master",
"require": {
"<originalvendorname>/<packagename>": "dev-master"
},
"minimum-stability": "dev"
}
Substitute with whatever you want, while originalvendorname/packagename is the fullname of the package.
In this case you are creating your own version of a package pulled from the git repo defined at your satis repo. What is not found there (the possible dependencies) will be pulled from each dependency's original git repo defined at the packagist.org repo.
When you made more modifications to your own version of the package and do some more commits, you need to update your satis repo. Re-build it as by the step #5 above.
In this way it will link to the last commit of your master branch (prefixed by 'dev-' in satis)
Hope this helps. The step by step commands are those found in the page you referred to at the beginning of your post.
composer.phar
,php composer.phar
orcomposer
are all alias name forthe way you call composer
. There is no clear default standard yet, and when reading it, you should change it to the way you usually call the composer command. The important part is the command after that. – Floe