Download the PHP package openium/symfony-toolkit without Composer

On this page you can find all versions of the php package openium/symfony-toolkit. 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 symfony-toolkit

Symfony toolkit

This symfony bundle provides abstractions for many common cases.

Installation

Open a command console, enter your project directory and execute:

For Symfony 7 use the v4

For Symfony 6 use the v3

For Symfony < 6 use the v2

Usage

AbstractController

Add 2 protected methods for controllers :

Filters

Add a class containing filters from the query parameters.

To get filters, use getFilterParameters in AbstractController.

You can also use FilterRepositoryUtils->applyFilters() to define the sort, limit and offset in queries.

Notes on filters :

PaginatedResult

The PaginatedResult allow you to have a formatted result for endpoints who used filters.

ServerService

This service provide a way to get the actual server url.

Add ServerServiceInterface with dependencies injection and use the method getBasePath() from it.

    function myFunc(ServerServiceInterface $serverService): mixed
    {
        // ...
        $basePath = $serverService->getBasePath();
        // ...
    }

FileUploaderService

This service help you to manage an entity with a uploaded file reference. Caution, this service allow only one upload property.

First, implements your entity with WithUploadInterface.

Next, you can use the WithUploadTrait, which contains certain methods and properties required by the interface.

Then inject into your entity event listener the FileUploaderServiceInterface service.

Finally, use the service like that :

    $fileUploaderService->prepareUploadPath($entity);
    $fileUploaderService->upload($entity);
    $fileUploaderService->removeUpload($entity);

AtHelper

Allow you to execute some commands with Unix AT command.


    // $cmd command to execute
    // $timestamp when the command will be executed
    // $path path where the at creation command will be executed
    // &$result result of at
    $output = $atHelper->createAtCommandFromPath($cmd, $timestamp, $path, $result);

    // get at job number
    $jobNumber = $atHelper->extractJobNumberFromAtOutput($output);
    $removeSuccess = $atHelper->removeAtCommand($jobNumber);

DoctrineExceptionHandlerService

Transform doctrine exceptions into HttpException.

In most cases, the exception will be a BadRequestHttpException.

But if the database error refers to a conflict, the method will throw a ConflictHttpException.

To use it, you need to inject DoctrineExceptionHandlerServiceInterface service.

        try {
            $this->em->persist($y);
            $this->em->flush();
        } catch (\Exception $e) {
            $this->doctrineExceptionHandlerService->toHttpException($e);
        }

Work fine with doctrine exceptions but not with other/custom exceptions


ExceptionFormatService

Transform exceptions to json Response. Exception's response is now generic, which means you can give your own code, text and message to the response.

In the case which you want to add secific code, firstly override the service of the bundle. You have to add your own service in config/services.yaml.

For example:

Then, you need to create an ExceptionFormatService in your project and extends the one in the bundle.

2 methods and one property can be override :

The exception you formatted is going to be used in the method formatExceptionResponse. This way you can handle a custom exception.

    $response = $this->exceptionFormat->formatExceptionResponse($exception);

PathExceptionListener

The listener catch kernel exceptions and transform them into HttpException thanks to ExceptionFormatService.

It is enabled by default and have this configuration :

parameters:
  openium_symfony_toolkit.kernel_exception_listener_enable: true
  openium_symfony_toolkit.kernel_exception_listener_path: '/api'
  openium_symfony_toolkit.kernel_exception_listener_class: 'Openium\SymfonyToolKitBundle\EventListener\PathExceptionListener'

it use the ExceptionFormatService to format automatically the kernel exceptions only for the routes defined in exception_listener_path parameter


MemoryUtils

Use to display memory usage or juste bytes into human-readable string.

$str = MemoryUtils::convert(1024);
// $str = '1 kb';

$phpMemory = MemoryUtils::getMemoryUsage();
// apply convert() to actual php memory usage

ContentExtractorService

Use to extract types data from array with specific key

    $myString = ContentExtractorUtils::getString($content, $key);

With option to allow null value, set a default value and set if value is required.

List of methods :

All methods throws 400 HTTP error with correct message if the value is missing or is not with the right type (depends of parameters)

Behind all these methods are control methods.

List of check methods :

Methods checkKeyIs{type} use checkKeyExists().

All the methods in this class are static.

DateStringUtils

Provide a static method to get date from string :

public static function getDateTimeFromString(
    string $dateString,
    ?string $format = null,
    ?DateTimeZone $timeZone = null
): DateTime | false

If no format has been supplied, the method attempts to determine the correct date format.

Two formats can be detected:

If no format is detected, the method falls back to the 'Y-m-d' format and return false if the string can't be parse as DateTime.


All versions of symfony-toolkit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-json Version *
ext-pdo Version *
symfony/http-foundation Version ^7.0
doctrine/orm Version ^2.6
symfony/validator Version ^7.0
symfony/http-kernel Version ^7.0
symfony/dependency-injection Version ^7.0
symfony/config Version ^7.0
symfony/framework-bundle Version ^7.0
symfony/monolog-bridge Version ^7.0
symfony/event-dispatcher Version ^7.0
symfony/translation Version ^7.0
symfony/monolog-bundle Version ^3.2
symfony/security-core Version ^7.0
symfony/finder Version ^7.0
symfony/filesystem Version ^7.0
symfony/console Version ^7.0
symfony/security-http Version ^7.0
symfony/orm-pack Version ^2.2
symfony/serializer Version ^7.0
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 openium/symfony-toolkit contains the following files

Loading the files please wait ....