Download the PHP package mmo/sf-utils without Composer

On this page you can find all versions of the php package mmo/sf-utils. 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 sf-utils

Symfony extensions

Validators

ITIN validator

ITIN - Individual Taxpayer Identification Number

Birthday

BankRoutingNumber

Utf8Letters

Only UTF-8 letters and dashes.

Utf8Words

Only UTF-8 letters, dashes, and spaces are allowed. Useful to validate the full name of a person.

OnlyDigits

Only digits are allowed.

ArrayConstraintValidatorFactory

Validators which don't follow a convention of naming a Constraint and ConstraintValidator, will not be found by the default implementation of ConstraintValidatorFactory.

The class ArrayConstraintValidatorFactory resolve this problem, you can map ConstraintValidator to object.

Translator

FakeTranslator

The FakeTranslator class can be used in a unit tests instead of using a stub. At the moment only id and locale arguments are supported.

Security

Encrypter

Encrypter is used to encrypt string value. All encrypted values are encrypted using OpenSSL and the AES-256-CBC cipher (as default).

AlwaysTheSameEncoderFactory (Symofny 4.4 and 5.4)

AlwaysTheSameEncoderFactory is useful in integration tests with combination of UserPasswordEncoder. No matter which implementation of UserInterface you pass, will always be used the same password encoder injected via constructor.

MemoryUserProvider (only Symfony 4.4 nad 5.4)

For Symfony 6.4+ use build-in provider \Symfony\Component\Security\Core\User\InMemoryUserProvider.

MemoryUserProvider is a simple non persistent user provider for tests.

This provider compares to InMemoryUserProvider allows for store any user objects, which implement the UserInterface interface instead of only the internal Symfony User class.

Form

RamseyUuidToStringTransformer

Transforms between a UUID string, and a UUID object. Symfony 5.3 include an own UuidToStringTransformer transformer, but you need also use a symfony/uuid component. This transformer works with a ramsey/uuid library.

PrimaryKeyToEntityTransformer

Transforms between a primary key(composite primary key is not supported), and an entity.

StringInsteadNullTransformer

The goal of this transformer is to fix an error when you have a form with ChoiceType and pass an empty value for this field and your entity/DTO expect only string value you get error "Expected argument of type "string", "NULL" given at property path ...".

The Symfony changes this empty string to null value (due to ChoiceToValueTransformer). You can add StringInsteadNullTransformer as a model transformer, so null values will be transformed to an empty string.

ReplaceIfNotSubmittedListener

The goal of this EventSubscriber is to overwrite data of model, when no data has been sent. Imagine scenario, that you have entities:

Property $person is not null. You want to set this value to null, because PersonDto cannot be in "split state". Both properties of PersonDto has to be set (cannot be empty). When the form is submitted, and Symfony parameter $clearMissing of method submit is set to false, then due to this EventSubscriber the property person of FormDto will be set to null value. Without this EventSubscriber, an empty PersonDto object will be created which will be passed to FormDto.

See also test \mmo\sf\tests\Form\ReplaceIfNotSubmittedFormTest.

lexik/jwt-authentication-bundle

Revoke JWT token

The JWT is stateful token. We don't need to store them. This property create problem, when we need to revoke (invalidate) a token. Some resources: How to change a token to be invalid status? or Invalidating JSON Web Tokens

In a file config/packages/cache.yaml we register a new pool cache.jwt. In this example as adapter we use Redis.

In a file config/routes.yaml we add a router:

Finally, we need to register services in config/services.yaml file. We create alias for interface JitGeneratorInterface to RamseyUuid4JitGenerator and configure listeners. For CheckRevokeListener we need pass correct arguments for cache pool (we create custom pool - cache.jwt in config/packages/cache.yaml) and router name api_logout, which we add in a file config/routes.yaml

Util

Transliterator

Class Transliterator contains one static method transliterate to returns transliterated version of a string. Based on yii2 Inflector

EntityTestHelper

The class EntityTestHelper helps set a value for a private field e.g. id.

ObjectHelper

arrayToObject

This static method recursive converts an array to stdClass.

Commands

S3CreateBucketCommand

Command mmo:s3:create-bucket creates a S3 bucket. When the option skip-if-exists is enabled, and the bucket exists the process will finish successful. You can use the option --public so everyone can get objects from a bucket.

To use this command you must register two services. In config/services.yaml register a service s3client and mmo\sf\Command\S3CreateBucketCommand.

LiipImagineBundle

ResolverAlwaysStoredDecorator

This resolver always returns true whether image already exists or not.

cyve/json-schema-form-bundle

CyveJsonSchemaMapper

The default implementation of data mapper (PropertyPathMapperTest) also set array key when the value is null This is a problem when fields in JsonSchema are not required. Schema validator doesn't check whether the field value is set. This is something different from the Symfony Validator component. In Symfony if the field value is the null or empty string, the validation is skipped. In JsonSchemaValidator event optional field with value null must match validation rules. Also cyve/json-schema-form-bundle not supported multiple types of field.

Doctrine

IgnoreSchemaTablesListener

This listener expects table names, which will be ignored during comparing database schema with entities. It is useful when you manually manage the table's schema for some of your entities. This is a similar solution to Manual tables from DoctrineMigrationsBundle

Serializer

MyCLabsEnumNormalizer

Normalizer and denormalizer for Enum class from package myclabs/php-enum.

MoneyNormalizer

Normalizer and denormalizer for Money class from package moneyphp/money.

EventSubscriber

PerformanceSubscriber

This listener connects to HttpKernel events (RequestEvent and TerminateEvent) to log the performance of an endpoint via LoggerInterface. The entry in the log includes duration, HTTP method, URL, and PID. Analysis of those data allows us to find the most time-consuming endpoints. We can have some suspects and start a deeper analysis of the performance of those endpoints via Xdebug or Blackfire.

Create a new channel and handler for monolog in config/packages/monolog.yaml.

Next register listener in config/services.yaml.

When we refresh page in log (in this configuration logs are sent to stderr) we should see something like this: [2021-08-30 15:15:19] performance.INFO: The request "GET /admin/login" took "1.041289" second. {"url":"/admin/login","method":"GET","pid":7,"status_code":200}


All versions of sf-utils with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2
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 mmo/sf-utils contains the following files

Loading the files please wait ....