How to Install and Use the Openjet Components¶
If you’re starting a new project (or already have a project) that will use one or more components, the easiest way to integrate everything is with Composer.
We assume you’re familiar with Composer and you have Composer installed globally.
Using the Core Component¶
If you’re creating a new project, create a new empty directory for it.
$ mkdir project
$ cd project
Open a terminal use Composer to add configuration and grab the library.
$ composer config repositories.openjet-core '{"type": "vcs", "reference": "master", "url": "git@gitlab.openjetlab.fr:openjet/core.git"}'
$ composer require openjet/core
Note
The name openjet/core is written at the top of the documentation for
whatever component you want.
Once Composer has downloaded the component(s), all you need to do is include
the vendor/autoload.php file that was generated by Composer. This file
takes care of autoloading all of the libraries so that you can use them
immediately. Open your favorite code editor and start coding:
<?php
// Sample script.php file.
require_once __DIR__.'/vendor/autoload.php';
use Openjet\Component\Core\Sanitizer\ColorSanitizer;
echo ColorSanitizer::sanitize('fff'); //Output: #fff
Now you can open the “script.php” file in browser or run it via console:
$ php script.php
Enjoy!