Skip to main content

Composer repository with Satis

How to create a composer repository with Satis and a Private GitHub repositories.

Following on the blog Composer based deployment for PHP projects, in this blog entry we will explain in more detail on how to create a composer repository with Satis and a private GitHub repositories. We opted for this process as it suits our development workflow best. Since we are working on our local development server, and therefore we do not require a separate GitHub account for all users. 

Requirements for your Server:  

Other Requirements:

Free Account on GitHub  

Create GitHub Repository and connect it to your local development:  

  1. Login to GitHub with your account  
  2. Create a new Repository   
  3. Add repository name, make sure repository is private
  4. Confirm by clicking on Create Repository

Congratulations, now you have an empty repository on GitHub, let us fill it up! For that, we need to create a local Git repository on the server and connect it to the GitHub repository. In this example, we will use an existing not-Git project with some content in it. Important is that your project has to contain a composer.json which describes the project. Please refer to the official documentation

Create local git repository:

  1. Connect to development server with SSH switch to your development user. I do not recommend using the root user of your system.
  2. cd to project folder, which you want to connect to your GitHub repository 
    cd ~/my-super-repository  
  3. Create a Git Project (Repository) 
    git init  
  4. Now add all the files inside this folder to the repository 
    git add
  5. Create your first commit  
    git commit -m "Initial Commit" 
  6. Change the name of the 'master branch to 'main' in your local repository, as GitHub changed the name of the 'master’ Branch to 'main': 
    git branch -M main 

If this went well, your local repository is ready to be connected. But as we created a private repository, this is the tricky part. Because we do not always want to log in to the repository when pushing something. There are a couple of ways to achieve this. I will use here the deploy key method.  

Connect local repository:

  1. Create an SSH key pair, NOTE: we need to have a unique key per repository as GitHub does not allow us to use the same SSH key more than once. Therefor, we specify a unique filename for this key.  
    ssh-keygen -f ~/.ssh/id_rsa.GITHUB_MY_SUPER_REPOSITORY 
  2. Authorize the key in our GitHub repository by taking the following steps:
    • Login to GitHub and navigate to your repository
    • GoTo Settings > Deploy Keys and click Add deploy key
    • Give it a title and copy the content of your public key 
      (cat ~/.ssh/
      Note: make sure that "Allow write access” is checked. 


  3. Tell the system to use this key when connecting to GitHub via SSH, defining it in the ~/.ssh/config (I'm using vim, but you can use any text editor) 
    vim ~/.ssh/config 
  4. Add the following content:
    Host github-my-super-repository 
    IdentityFile /home/dev/.ssh/id_rsa.GITHUB_MY_SUPER_REPOSITORY
    For more information about the usage of this .ssh/config check out this link.
  5. Do a quick test to see if the setup is correct: 
    ssh git@github-my-super-repository 
    You know it is ok when the response is something like:
    Hi RafaelYD/my-super-repository! You've successfully authenticated, but GitHub does not provide shell access. 
    Connection to closed.

  6. Now you can connect to your local repository to the remote GitHub repository, by running the following command via SSH in your local Git repository:
    git remote add origin git@github-my-super-repository:RafaelYD/my-super-repository.git 

Note: As we are using git@github-my-super-repository, we do not need to worry about authentications. This is important for the setup of our composer Repository with Satis. Which is what we are going to do now. Don’t worry, the worst part is over. This next part is child's play!

Assuming that you have installed Satis via Composer as specified in the documentation. We will not go into detail here on how to set Satis up and all the features it offers. We will just look at an example on how to configure the satis.json for our Composer repository.  

"As we are using git@github-my-super-repository, we do not need to worry about authentications."

Set up composer repository with Satis: 

The satis.json for our example looks like this:    

    "name": "My Composer Repo", 

    "homepage": "", 

    "archive": { 

        "directory": "dist", 

        "absolute-directory" : "/absolute/path/to/satis/web/dist/", 

        "format": "zip" 



        "type":"vcs", "url":"git@github-my-super-repository:RafaelYD/my-super-repository.git" 


        "type":"vcs", "url":"git@github-my-other-repository:RafaelYD/my-other-repository.git" 


    "output-html": true, 

    "require-all": true 

A quick overview of the most important parts:  



Reasons / annotations  


Allows us to archive the content of our repositories in a predefined directory. In this case:  

The repositories will be zipped in the directory list with the absolute path /absolute/path/to/satis/web/dist/  

As a result, we always have a file on our server, and Satis will not depend on the connection to GitHub when a package is required  


List of repositories where also our created repository is listed. Please see the documentation for details and supported types. For our purpose we use the type: vcs and in the url:  git@github-my-super-repository so Satis can authenticate.  

If your repository is not on the same server as your development, you will need to add a deploy-key for that server also.

There you go! Now you will be able to deploy your project with Composer. You see that the first setup may be a little tricky. But once done, the fast deployment will pay for itself. And with GitHub and versioning control, you always have a backup. If necessary, you can easily roll back your changes.  

You can read more about why, in the article Composer based deployment for PHP projects.

This article was written by Rafael our Full stack developer


Also a project like this one?

Drop us a line, we are here to listen to your challenges. Let´s make success.

Somos Agente Digitalizador Kit Digital