The core package of Luminar PHP ecosystem, providing essential functionality and structure

dev-main 2024-09-06 13:08 UTC

This package is auto-updated.

Last update: 2025-04-06 14:33:25 UTC


README

Tests Status

Luminar Core is the foundational package for the Luminar PHP framework, providing the providing essential functionality and core components needed to build applications.

Table of Contents

Introduction

Luminar Core is a PHP library that includes the core components of the Luminar framework. This package provides the service container, configuration management, event dispatching, and utility functions.

Features

  • Service Container: A powerful dependency injection container
  • Configuration Management: Load and manage configuration files in YAML format.
  • Event Dispatching: A flexible event system for handling application events.
  • Utility Functions: Helpful functions for string manipulation and general utilities.

Installation

You can install Luminar Core using Composer, Run the following command in your project directory:

composer require luminar-organization/core

Usage

Service Container

Bind and resolve services using the Container class:

use Luminar\Core\Container\Container;

$container = new Container();

$container->bind('example', function() {
    return new \SomeClass();
});

$instance = $container->resolve('example');

Configuration Management

Load configuration files and retrieve values:

use Luminar\Core\Config\Config;

$config = new Config('/path/to/config');

$value = $config->get('database.host', 'localhost');

Event Dispatching

Register and dispatch events using the EventDispatcher class:

use Luminar\Core\Events\EventDispatcher;

$dispatcher = new EventDispatcher();

$dispatcher->listen('event.name', function($data) {
    // Handle the event
});

$dispatcher->dispatch('event.name', $data);

Utility Functions

Use helper and string utility functions:

use Luminar\Core\Support\Helpers;
use Luminar\Core\Support\Str;

$emailValid = Helpers::isValidEmail('test@example.com'); // Output will be boolean
$randomStr = Helpers::randomString(12); // Output will be random string length of 12 characters
$humanizedStr = Helpers::humanize('hello_world'); // Output will be Hello World

$snakeCase = Str::snakeCase('HelloWorld'); // Output will be hello_world
$camelCase = Str::camelCase('hello_world'); // Output will be helloWorld
$titleCase = Str::titleCase('hello world'); // Output will be Hello World

Testing

To run the tests, ensure you have installed all development requirements:

composer install

After that run all tests:

composer run test

This will execute all tests located in the tests/ directory and provide feedback on the test results.

Contributing

We welcome contributions to Luminar Core! Please follow these steps to contribute:

  • Fork the repository
  • Create a new branch for your feature or bugfix
  • Make your changes and add tests if applicable
  • Submit a pull request with a clear description of your changes

Please refer to the CONTRIBUTING.md file for more details

License

Luminar Core is licensed under the MIT License. See the LICENSE file for more information

For more information about Luminar, visit our website or docs