The Dev Core Library is a versatile utility designed to streamline the setup and initialization of PHP libraries within your Devinci framework project. It provides essential functionality for creating directories, updating composer.json
, and generating configuration files.
To integrate the Dev Core Library into your project, follow these steps:
Clone the library from the Devinci PHP Toolbox GitHub repository:
git clone https://github.com/devinci-it/Devinci-PHP-Toolbox.git
Use the DevCore
class to set up and configure your PHP libraries. Here's an example script:
<?php
require_once "../vendor/autoload.php";
use Devinci\DevCore\DevCore;
// Load configuration
DevCore::loadConfig();
$libName = 'your-library-name';
$classes = ['YourClass1', 'YourClass2'];
DevCore::setupLibrary($libName, $classes);
Adjust library configuration by modifying the config.ini
file in the DevCore
directory. Configuration options include:
- vendor_name: Vendor name for the new library.
- base_library_path: Base path for the new library.
- composer_json_path: Path to the main
composer.json
file.
The ScriptHandler
class offers a set of methods for handling various Composer events. For example, postAutoloadDump
generates a config.ini
file and provides information about the setup.
Example:
<?php
namespace Devinci\DevCore;
use Composer\Script\Event as ScriptEvent;
class ScriptHandler
{
const INI_FILE = __DIR__ . '/config.ini';
public static function postAutoloadDump(ScriptEvent $event)
{
// ... (see previous conversation for the complete method)
}
}
<?php
namespace Devinci\DevCore;
class ScriptHandler
{
const CONFIG_FILE = __DIR__ . '/../../config.php';
public static function generateConfigPhp($vendorName, $libraryName)
{
// ... (see previous conversation for the complete method)
}
}
// Usage in a script:
ScriptHandler::generateConfigPhp('devinci', 'dev-core');
If you encounter issues or have suggestions for improvements, feel free to open an issue or submit a pull request. We welcome contributions from the community.
This library is licensed under the MIT License - see the LICENSE file for details.