Getting Started

Add a new project

1 Implementation of token

Firstly, you need to add the token which has been generated when you created your project.

First way:
Create a new file named "cmc-token.txt" in the same directory as your composer.json file and paste your token.

Second way:
Store your token in "extra" node of your composer.json file, like this:

"extra": {
    ...
    "cmc-token": "mytoken",
}

Your token is like a password, don't share it. If you project will be visible on public places like Github, prefer the file solution and add it into your .gitignore.

If you only want to synchronize your project in production environment, we suggest to use the first way with a file only stored on your production server.

2 Add CmC dependency to your composer

Now, just add our package in your composer dependencies:

composer require checkmycomposer/commands

If you have the following error (this occurs because there is not yet stable version of Composer), follow our help documentation to solve it:

Your requirements could not be resolved to an installable set of packages.

Don't forget to add the following autoload in your composer.json

"autoload": {
    ...
    "psr-4": {"CmC\\": "vendor/checkmycomposer/commands/CmC"}
}

3 Add synchronization command on Composer events

To manually execute the commands in your console, add the following code:

"scripts": {
    ...
    "check": "CmC\\CheckMyComposer::check",
    "synchro": "CmC\\CheckMyComposer::synchronize"
}

To automatically synchronize your project with our service, we invite you to add synchronize command in post-install-cmd and post-update-cmd event:

"scripts": {
    "post-install-cmd": [
        ...
        "CmC\\CheckMyComposer::synchronize"
    ]
    "post-update-cmd": [
        ...
        "CmC\\CheckMyComposer::synchronize"
    ]
}

Use commands lines

Check directly your dependencies in your console

To check your dependencies, type the following command in the directory where your composer.json file is stored.

composer check

A table will be displayed with all dependencies you are using with several information as in the following image.

Result of composer check command

You can change the alias of the command ("check") in the "scripts" node of your composer.json file (see section above).

Synchronize your projects with CheckMyComposer

The main interest of CheckMyComposer is to follow your projects very easily.
To complete this, you need to type the following command in the same directory as your composer.json file.
Don't forget to store your synchronization token (see section Implementation of token).

composer synchro

A message will inform you that the synchronization has been succesfully done.

Result of composer check command

As the checking command, you can change the alias of the command ("synchro") in the "scripts" node of your composer.json file.

We suggest you to synchronize your projects in production environment (this has more interest to follow real versions used by your projects in production).
As indicated in "Implementation of token" part, we recommend to store your token in a file (only present in your production server) in this case.