Download the PHP package baraja-core/service-method-invoker without Composer

On this page you can find all versions of the php package baraja-core/service-method-invoker. 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 service-method-invoker

Service Method Invoker

Integrity check

A robust PHP library for safely invoking methods on services with automatic parameter validation, type coercion, and entity hydration. Perfect for API endpoints, command handlers, and any scenario where you need to dynamically call methods with user-provided data.

🎯 Key Features

🏗️ Architecture

The package consists of several components working together to provide safe method invocation:

🔧 Components

Component Description
ServiceMethodInvoker Main class responsible for invoking methods with validated and hydrated parameters
Service Interface for services that extends Stringable for user-friendly error messages
RuntimeInvokeException Exception class that carries service context, method name, and parameters for debugging
BlueScreen Tracy Debugger integration that renders detailed error panels with source code
Helpers Utility class for type resolution, annotation parsing, and use statement extraction
ProjectEntityRepository Interface for custom entity resolution by ID (e.g., Doctrine integration)

📦 Installation

It's best to use Composer for installation, and you can also find the package on Packagist and GitHub.

To install, simply use the command:

You can use the package manually by creating an instance of the internal classes, or register a DIC extension to link the services directly to the Nette Framework.

Requirements: PHP 8.1 or higher

🚀 Basic Usage

Simple Method Invocation

Think of a simple service as an API endpoint with a public method for hydrating your data:

And your endpoint can be:

Getting Invoke Arguments Without Execution

If you need to prepare the arguments without actually invoking the method:

🎭 Type Coercion

The invoker automatically handles type conversion based on method parameter types:

Scalar Types

Nullable Parameters

When a parameter is nullable and receives an empty or falsy value, it's converted to null:

Boolean Conversion

The following string values are treated as true: "1", "true", "yes" (case-insensitive). All other values are converted to false.

📊 Entity Hydration

One of the most powerful features is automatic entity/DTO hydration from array data:

Simple Entity

Nested Entities

The invoker supports nested entity hydration:

Property Hydration via Setters

If an entity has setter methods, they will be used for hydration:

Circular Reference Detection

The invoker detects and prevents circular references in entity hydration:

🔢 PHP 8.1+ Enum Support

The invoker fully supports PHP enums with case-insensitive matching:

If an invalid enum value is provided, a helpful error message is shown:

🔍 Custom Entity Repository

For integrating with ORMs like Doctrine, implement the ProjectEntityRepository interface:

This allows automatic entity resolution from IDs:

📑 The Data Parameter

When dataMustBeArray is true, a parameter named data must be typed as array and will receive all input parameters:

🐛 Tracy Debugger Integration

When Tracy Debugger is available, the package automatically registers a custom BlueScreen panel that provides:

This integration is automatic when Tracy is installed - no configuration needed.

⚠️ Exception Handling

The RuntimeInvokeException provides rich context for debugging:

Common Exceptions

Scenario Exception Type
Method doesn't exist InvalidArgumentException
Method is not callable InvalidArgumentException
Required parameter missing RuntimeInvokeException
Invalid enum value RuntimeInvokeException
Type incompatibility RuntimeInvokeException
Circular reference in entities RuntimeInvokeException
Entity class doesn't exist RuntimeInvokeException

🎨 Service Interface

Implement the Service interface on your services for better error messages:

📋 DateTime Handling

DateTimeInterface implementations are automatically instantiated:

🔒 Default Values for Empty Inputs

When a non-nullable parameter receives an empty value, appropriate defaults are used:

Type Default Value
string "" (empty string)
int 0
float 0.0
bool false
array []

👤 Author

Jan Barasek - https://baraja.cz

📄 License

baraja-core/service-method-invoker is licensed under the MIT license. See the LICENSE file for more details.


All versions of service-method-invoker with dependencies

PHP Build Version
Package Version
Requires php Version ^8.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 baraja-core/service-method-invoker contains the following files

Loading the files please wait ...