PHP code example of drewlabs / libman

1. Go to this page and download the library: Download drewlabs/libman library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

drewlabs / libman example snippets


use Drewlabs\Libman\LibraryConfig;
use Drewlabs\Libman\LibraryInstallerFactory;

// Creates an instance of the library to install
// API: LibraryConfig::new(string name, string type, string package)
$library = LibraryConfig::new('ClientLibrary', 'composer', 'client/library');

use Drewlabs\Libman\LibraryConfig;
use Drewlabs\Libman\LibraryInstallerFactory;

// Creates an instance of the library to install
// API : LibraryConfig::new(string name, ?string type, ?string package, string $factoryClass)
$library = LibraryConfig::new('ClientLibrary', null, null, ClientLibraryFactory::class);

use Drewlabs\Libman\LibraryManager;
use Drewlabs\Libma\InMemoryConfigurationRepository;
use Drewlabs\Libman\YAMLDefinitionsProvider;

$repository = new InMemoryConfigurationRepository(YAMLDefinitionsProvider::create('./path/to/libman.yml'));
$libManager =  new LibraryManager($repository);

// Create an instance a composer based library named 'drewlabs/crypt'
$libManager->resolveInstance('drewlabs/crypt');

use Drewlabs\Libman\LibraryManager;
use Drewlabs\Libman\LibraryConfig;

// Create an Instance of the library 
$instance = LibraryManager::createInstance(LibraryConfig::new('ClientLibrary));