Download the PHP package locky42/leopard-core without Composer

On this page you can find all versions of the php package locky42/leopard-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package leopard-core

Leopard Core

leopard-core is the core library for the Leopard Framework, providing essential features such as routing, attributes, dependency injection container, and other foundational components.


Table of Contents


Installation

Install leopard-core using Composer:


Core Components

Dependency Injection Container

The Container is a simple dependency injection container that allows you to register services and retrieve their instances.

Example:


Routing

The Router allows you to define routes using attributes, YAML configuration, and automatic route generation based on controller structure.

Routing Methods

  1. Attribute-based routing - Define routes using PHP attributes
  2. YAML configuration - Define routes and controller paths in YAML
  3. Auto-routing - Automatic route generation for methods ending with Action suffix

Action Method Convention

For auto-routing (YAML controllers), only methods ending with Action suffix are processed as routes:

Examples:

Attribute-based Routing Example:

YAML Configuration Example:

YAML Controllers Behavior

Dynamic Parameters in Paths

The router supports these placeholders in route paths:

If a parameter type in controller method is int|float|bool and conversion fails, router returns 404.

HEAD requests are allowed to match GET routes.

Auto-routing with loadControllersFrom:


Attributes

leopard-core supports PHP attributes for defining routes and other metadata.

Example:


ContractFactory

The ContractFactory is a universal factory for creating instances through interface contracts. It enables flexible dependency management by allowing you to register and swap implementations without modifying existing code.

Key Benefits:

Basic Usage:

Swapping Implementations:

Available Methods:

Integration Example:

Doctrine Integration (auto ResolveTargetEntity)

If locky42/leopard-doctrine is installed, ContractFactory::register(...) automatically forwards the mapping to ResolveTargetEntityRegistry::addResolveTargetEntity(...).

You can also pass Doctrine mapping options as the third argument:

In application projects, keep all contract mappings in one file (for example config/contract-mappings.php) and include it in bootstrap.

Best Practices:

  1. Always use ::class syntax:

  2. Register at application bootstrap:

  3. Use type hints with interfaces:

  4. Clear mappings in tests:

Error Handling:

The factory throws InvalidArgumentException in these cases:


View

The View class is responsible for rendering templates and managing the presentation layer. It supports layouts, blocks, and integration with the SEO service.

Features:

Example:

Rendering Blocks:


SEO

The Seo service manages SEO metadata for your pages, including meta tags, Open Graph, Twitter Cards, and more.

Features:

Example:

Rendering SEO Tags in Layout:


Usage Examples

Loading Configuration


Testing

To run tests, use the following command:

The tests are located in the vendor/locky42/leopard-core/tests directory.


License

This project is licensed under the MIT License.


All versions of leopard-core with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
psr/container Version ^2.0
symfony/yaml Version ^7.3
nyholm/psr7 Version ^1.8
nyholm/psr7-server Version ^1.1
locky42/leopard-events Version ^1.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package locky42/leopard-core contains the following files

Loading the files please wait ...