Skip to main content

Composer based deployment - PHP projects

For those who do not have experience with Composer and want to enrich their workflow and make deployment fast and more reliable.

Every PHP developer stumbles upon the Dependency Manager Composer at least once in his career. Probably the majority of us is already working with it on their PHP projects.  

This article is for those who do not have experience with Composer and want to enrich their workflow and make deployment fast and more reliable.     

What is Composer?   

Composer is a dependency manager for PHP.  It allows you to define libraries and system requirements (like PHP version) your project is depending on.   
For a more detailed introduction, visit the official website

Why deployment with Composer?  

We were working in the “traditional” way, developing and debugging on our local dev server, and then coping the ready solution via rsync to the production server of our clients. This did not always work out as expected and led to issues and sometimes even downtimes of the websites, caused by:  

  • System incompatibilities – e.g. different PHP version  
  • Missed files in copy process  
  • Overwrites of "fast" bug fixes on production server    

I was looking for a way to tackle these issues and decrease time and frustration in deploying our solutions on the production servers of our clients.  

As I have been working on many Magento 2 modules, I was already familiar with the Composer and how to use it to implement external modules in various Magento 2 installations. This is why I think that deployment of PHP projects should be done with Composer. And not only Magento 2 modules, but all kinds of reusable projects could make use of Composer.  

For what kind of projects should you use Composer? 

I learned that it’s not required to convert each project into a Composer based project. In my opinion, the Composer can enrich the following types of PHP projects:

  • Plugins and Modules - Magento 2, Typo3 and other CMS Systems that are using Composer to integrate the custom modules within their installation.  
  • Frameworks – when you are building a framework which you want to reuse in other projects.

My message is: "Do not reinvent the wheel!" - You need a framework or Api connector or other functionality. Some Composer package libraries for sure have available. Check out Packagist for example.

How to make a project compatible with Composer?   

To make our modules and solutions compatible with Composer, our workflow required adaptation. We reconsidered the following points: 

  • All our development code isn't publicly accessible.  
  • The solution should not be cost intensive.
  • Current workflow should not be alternated, except the deployment part of course.
  • Deployment should be possible by anyone of the team, in other words; as simple as possible.

These points in mind, I decided for the following setup: 

  • Git Repository on GitHub - for version control 
  • Satis as Composer repository, which I installed on our local server  

The reasons why I decided for this setup are as follows.  

Why include Satis?

To make our project available for Composer, Composer repository was required. And when I was looking for this, Packagist popped up. As their pricing model did not match our needs and would mean high future expenses, this option was discarded. We decided to go for Satis as there are not many other free or open source alternatives. Let's see why:

  • It is open source, so we can run it on our own server, and it's free!
  • Easy to manage (one json file), and can be automated  
  • Works good with Git repositories hosted on GitHub 
  • Gives us full Control on who can see and use our repository  

For GitHub 

A version control system was required, as the Composer repository package requires some kind of versioning. So the end user can require an older version of the package or even custom developments. was the best option for me personally because:  

  • I already worked with Git repositories and GitHub  
  • I don’t have experience with alternative systems like Bitbucket or svn  
  • It is very easy to create new repositories  
  • It can connect to our ticket system Jira  

How does deployment work with the setup? 

Deployment with this setup works as follows:  

  1. After development is finished, the changes need to be committed to the GitHub Repository.
  2. If it’s a new version release, GitHub gives you the possibility to create a release and give it a version number.
  3. The Satis build command has to be executed, which downloads and zips the newest version to the composer repository. 
  4. As the newest version is now available in the Composer repository, we just need to run the Composer required command on the target server and done.    

We can conclude that the initial setup of a project may take more time, because you have to create a repository on GitHub and connect your project. But the time and security you gain in the deployment makes it worth it. Also, a big gain is the availability of multiple versions of your projects, which increases the range where your project can be applied.  

This entry was written by Rafael our Full stack developer

More articles

Embracing the Future: Migrating to Google GA4 and Preserving Your Data in BigQuery
Unveil new opportunities and potential insights amid the shift from Universal Analytics to Google Analytics 4. Navigate this digital transition with…
Read more
Shopify Saas vs Magento Open Source self-owned
Read how we made the discission between SaaS and Open source in 2022. Because there is a lot to take into account.
Read more
Composer repository with Satis

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

Read more
Composer based deployment - PHP projects

For those who do not have experience with Composer and want to enrich their workflow and make deployment fast and more reliable.

Read more
eCommerce project

Getting that digital sales experience right.

Read more
Review Package React-Bootstrap

The React-Bootstrap package; a rebuilt version of the popular front-end framework for React.

Read more
Amazon EU Order Sync Module
Automatically sync between Amazon and Magento with the Amazon EU Order Sync Module for Magento 2, and save time!
Read more
Magento Speed Module
We built a package to improve your Magento store speed up considerably. Say goodbye to slow page loading and get your online sales speed at the right…
Read more
We developed an extension onto the bundle product functionality of Magento that loads an interactive selection with graphical output. The module can…
Read more
Down Payment Module Magento 2
Downpayments or spread payments for Magento 2 are very common when orders come in large amounts. The customer makes an initial payment as a deposit…
Read more
Technical configurator
This technical configurator allows the technical product to be loaded with all variables and options. Depending on the selection the configurator…
Read more
AGB Module
Avoid hassle with German Law regulations!
Read more
Hreflang Module
A small advanced SEO module for Magento that loads the right SEO Hreflang tag inside Magento to get your international stores ranked high. Get your…
Read more
Quotation Module
One way of increasing your sales, is offering your customers a quote before they proceed with their purchase.
Read more
PIM, Special software or just a term...
Read more
Is your catalogue price rule condition not working on Magento and are you using bundle products? The cause is in the simple products that create the…
Read more
An image library specially built for the car industry. It loads the right car image with an associated product.
Read more

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