Download the PHP package vrok/symfony-addons without Composer

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

vrok/symfony-addons

This is a library with additional classes for usage in combination with the Symfony framework.

CI Status Coverage Status

Mailer helpers

Automatically set a sender address

We want to replace setting the sender via mailer.yaml as envelope (@see https://symfonycasts.com/screencast/mailer/event-global-recipients) as this would still require each mail to have a FROM address set and also doesn't allow us to set a sender name.

config/services.yaml:

.env[.local]:

Messenger helpers

Resetting the logger before/after a message

We want to group all log entries belonging to a single message to be grouped with a distinct UID and to flush a buffer logger after a message was processed (successfully or failed), to immediately see the entries in the log:

config/services.yaml:

Validators

AtLeastOneOf

Works like Symfony's own AtLeastOneOf constraint, but instead of returning a message like This value should satisfy at least ... it returns the message of the last failed validation. Can be used for obviously optional form fields where only simple messages should be displayed when AtLeastOne is used with Blank as first constraint.
See AtLeastOneOfValidatorTest for examples.

NoHtml

This validator tries to detect if a string contains HTML, to allow only plain text.
See NoHtmlValidatorTest for examples of allowed / forbidden values.

NoLineBreak

This validator raises a violation if it detects one or more linebreak characters in the validated string.
Detects unicode linebreaks, see NoLineBreaksValidatorTest for details.

NoSurroundingWhitespace

This validator raises a violation if it detects trailing or leading whitespace or newline characters in the validated string. Linebreaks and spaces are valid within the string.
Uses a regex looking for \s and \R, see NoSurroundingWhitespaceValidatorTest for details on detected characters.

PasswordStrength

This validator evaluates the strength of a given password string by determining its entropy instead of requireing something like "must contain at least one uppercase & one digit & one special char".
Allows to set a minStrength to vary the requirements. See Vrok\SymfonyAddons\Helper\PasswordStrength for details on the calculation.

PHPUnit helpers

Using the ApiPlatformTestCase

This class is used to test ApiPlatform endpoints by specifying input data and verifying the response data. It combines the traits documented below to refresh the database before each test, optionally create authenticated requests and check for created logs / sent emails / dispatched messages. It allows to easily check for expected response content, allowed or forbidden keys in the data or to verify against a given schema.

Requires "symfony/browser-kit" & "symfony/http-client" to be installed (and of cause ApiPlatform).

Option Usage Example
skipRefresh if set & true the database will not be refreshed before the request, to allow using two calls to `testOperation` in one testcase, e.g. uploading & deleting a file with two requests `'skipRefresh' => true`
prepare Callable, to be executed _after_ the kernel was booted and the DB refreshed, but _before_ the request is made
uri the URI / endpoint to call `'uri' => '/users'`
iri an array of `[classname, [field => value]]` that is used to fetch a record from the database, determine its IRI, which is then used as URI for the request `'iri' => [User::class, [email => '[email protected]']]`
email if given, tries to find a User with that email and sends the request authenticated as this user with lexikJWT bundle `'email' => '[email protected]'`
postFormAuth if given (and 'email' is set) the JWT from Lexik is sent as 'application/x-www-form-urlencoded' request in a form field.
This is used for download endpoints where the browser should present the user with the file to download instead of loading it into memory via Javascript. (As we don't want to supply the token via GET to prevent security issues and as we cannot set a cookie.)
`'postFormAuth' => 'bearer'`
method HTTP method for the request, defaults to GET. If PATCH is used, the content-type header is automatically set to `application/merge-patch+json` (if not already specified) `'method' => 'POST'`
requestOptions options for the HTTP client, e.g. query parameters or basic auth
files An array of one or more files to upload. The files will be copied to a temp file, and wrapped in an `UploadedFile`, so the tested application can move/delete it as it needs to. If this option is used, the content-type header is automatically set to `multipart/form-data` (if not already specified)
responseCode asserts that the received status code matches `'responseCode' => 201`
contentType asserts that the received content type header matches `'contentType' => 'application/ld+json; charset=utf-8'`
json asserts that the returned content is JSON and contains the given array as subset
requiredKeys asserts the dataset contains the list of keys. Used for elements where the value is not known in advance, e.g. ID, slug, timestamps. Can be nested.
forbiddenKeys like requiredKeys, but the dataset may not contain those
schemaClass Asserts that the received response matches the JSON schema for the given class. If the `iri` parameter is used or the request method is *not* GET, the item schema is used. Else the collection schema is used.
createdLogs array of entries, asserts the messages to be present (with the correct log level) in the monolog handlers after the operation ran
emailCount asserts this number of emails to be sent via the mailer after the operation was executed
messageCount asserts this number of messages to be dispatched to the message bus
dispatchedMessages Array of message classes, asserts that at least one instance of each given class has been dispatched to the message bus. An Element can also be an array of [FQCN, callable], in that case the callback is called for each matching message with that message as first parameter and the JSON response as second parameter, to trigger additional assertions for the message.
dispatchedEvents Array of event names (may be class names), asserts that at least one instance of each given event has been dispatched to Symfony's EventDispatcher.

Using the RefreshDatabaseTrait

(Re-)Creates the DB schema for each test, removes existing data and fills the tables with predefined fixtures. Install doctrine/doctrine-fixtures-bundle and create fixtures, the trait uses the test group per default.

Just include the trait in your testcase and call bootKernel() or createClient(), e.g. in the setUp method:

Optionally define which fixtures to use for this test class:

Supports setting the cleanup method after tests via DB_CLEANUP_METHOD. Allowed values are purge and dropSchema, for more details see RefreshDatabaseTrait::$cleanupMethod.

Using the AuthenticatedClientTrait

For use with an APIPlatform project with lexik/jwt-authentication-bundle. Creates a JWT for the user given by its unique email, username etc. and adds it to the test client's headers.

Include the trait in your testcase and call createAuthenticatedClient:

Using the MonologAssertsTrait

For use with an Symfony project using the monolog-bundle.
Requires monolog/monolog of v3.0 or higher.

Include the trait in your testcase and call prepareLogger before triggering the action that should create logs and use assertLoggerHasMessage afterwards to check if a log record was created with the given message & severity:

Workflow helpers

Require symfony/workflow.

PropertyMarkingStore

Can be used instead of the default MethodMarkingStore, for entities & properties without Setter/Getter.

workflow.yaml:

services.yaml:

WorkflowHelper

Allows to get an array of available transitions and their blockers, can be used to show the user what transitions are possible from the current state and/or why a transition is currently blocked.

Cron events

Adding this bundle to the bundles.php registers three new CLI commands:

When these are called, they trigger an event (CronHourlyEvent, CronDailyEvent, CronMonthlyEvent) that can be used by one ore more event listeners/subscribers to do maintenance, push messages to the messenger etc. It is your responsibility to execute these commands via crontab correctly!

ApiPlatform Filters

SimpleSearchFilter

Selects entities where the search term is found (case insensitive) in at least one of the specified properties. All specified properties type must be string.

Requires CAST as defined Doctrine function, e.g. by vrok/doctrine-addons:

ContainsFilter

Postgres-only: Filters entities by their jsonb fields, if they contain the search parameter, using the @> operator. For example for filtering for numbers in an array.

Requires CONTAINS as defined Doctrine function, provided by vrok/doctrine-addons:

JsonExistsFilter

Postgres-only: Filters entities by their jsonb fields, if they contain the search parameter, using the ? operator. For example for filtering Users by their role, to prevent accidental matching with overlapping role names (e.g. ROLE_ADMIN and ROLE_ADMIN_BLOG) when searching as text with WHERE roles LIKE '%ROLE_ADMIN%'.

Requires JSON_CONTAINS_TEXT as defined Doctrine function, provided by vrok/doctrine-addons:

MultipartDecoder

Adding this bundle to the bundles.php registers the MultipartDecoder to allow handling of file uploads with additional data (e.g. in ApiPlatform):

The decoder is automatically called for multipart requests and simply returns all POST parameters and uploaded files together. To enable this add the multipart format to your config\api_platform.yaml:

FormDecoder

Adding this bundle to the bundles.php registers the FormDecoder to allow handling HTML form data in ApiPlatform:

The decoder is automatically called for form requests and simply returns all POST parameters. To enable this add the form format to your config\api_platform.yaml:

Twig Extensions

Adding this bundle to the bundles.php together with the symfony/twig-bundle registers the new extension:

FormatBytes

Converts bytes to human-readable notation (supports up to TiB).
This extension is auto-registered.
In your Twig template:

Outputs: 9.34 MiB

Developer Doc

composer.json require

composer.json dev

Open ToDos


All versions of symfony-addons with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
symfony/framework-bundle Version ^7.0.0
symfony/yaml Version ^7.0.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 vrok/symfony-addons contains the following files

Loading the files please wait ....