Question

I am really new to Satis and I found this tutorial: https://getcomposer.org/doc/articles/handling-private-packages-with-satis.md.

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?

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. 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.

So, how could I install Satis and use it? Do you know any video tutorial that teach us on this? I can't find any on Youtube.

Thank you.

Was it helpful?

Solution 2

After you download satis, you need to create a config json file with the location towards your repositories. Name it whatever you like. After that, execute the bin/satis command to create your web viewer. Something like

php bin/satis build mi-config.json web/

If the latter command works you have configured correctly your satis server. Then, all you need to do is to include your repositories source in the main composer.json file:

"repositories": [
    {
        "type": "composer",
        "url": "http://localhost/satis/web"
    }
],
"require": {
    "my/package: "*"
},

Something I noticed in your question:

I tried to run composer.phar create-project ...

I get error message saying that composer.phar is not found. So, I try with composer create-project...

You don't need to install composer on every project on your server as it works for every project as long you move it to a shared route (as documentation says aka /usr/local/bin/composer - without the phar extension). Just keep in mind that the first example is in case you have the composer in your project root (with the full name and extension) and the second tries to use the composer located in your user/local path.

It's not a video but hope it helps Regards

OTHER TIPS

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:

  1. install composer globally (for simplicity, and you have it already)
  2. in a folder that will become available from the web, install satis
  3. 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
  4. Add a satis.json file inside your satis repo with definitions for your project
  5. 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": "satis@satis.mydomain.com:<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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top