-
Notifications
You must be signed in to change notification settings - Fork 2
Development Environment
The Transfer Object repository includes a development environment facilitated by a Docker SDK shell script.
To view all available commands and arguments (e.g., phpunit, phpstan, etc.), run the following command:
$ docker/sdkImportant
To begin working with the Transfer Object project, please ensure you have Docker and Docker Compose installed on your system.
Execute command bellow to install the Project:
$ docker/sdk installNote
CaptainHook is a Git hook library for PHP projects.
$ docker/sdk hook-installVerify CaptainHook Installation:
$ docker/sdk hook config:infoIn order to add docker/sdk autocomplition and its alias ds:
- Add to
~/.bashrc, replacing{project-path}with your project path:
# source the composer autocompletion script
if [ -f {project-path}/docker/bash/sdk-autocomplete.sh ]; then
source {project-path}/docker/bash/sdk-autocomplete.sh
fi
# ds alias
alias ds="docker/sdk"- Reload shell
$ source ~/.bashrc- Test alias autocompletion by typing
dsfollowed by<tab> - Test full command autocompletion by typing
docker/sdkfollowed by<tab>
To actualize definition.schema.json with new Symfony constrains attributes, following shell script should be executed:
#!/bin/bash
# Configuration
DIRECTORY="vendor/symfony/validator/Constraints"
PREFIX="sf-assert:"
# Check if directory exists
if [ ! -d "$DIRECTORY" ]; then
echo "Error: Directory $DIRECTORY not found."
exit 1
fi
# Search for PHP files containing the Attribute marker
# Sort the results
# Extract the filename without extension
# Prepend the prefix and wrap in JSON format
grep -l "#\[\\\\Attribute(" "$DIRECTORY"/*.php | xargs -I {} basename {} .php | sort | sed "s/.*/{ \"const\": \"$PREFIX&\" },/"To actualise the configuration list var/config/config.list.txt following command should be executed:
$ find . -type f -name "*.config.yml" > ./var/config/config.list.txtTo see how the Transfer Object generator works, please follow the steps below:
- Add or edit a definition file in:
examples/config/transfer-generator/definition - Run the console command to generate Transfer objects:
$ docker/sdk to-generate ./examples/config/transfer-generator/generator.config.yml- Check the generated Transfer objects in:
examples/Generated/TransferGenerator
Tip
The examples examples/try-transfer-generator.php illustrate how to generate Transfer objects using the Facade methods. They can also be used as a playground for Transfer objects generated by the console command as well. You can run examples from your IDE (using the container's PHP) or inside Docker container.
Running the console command without argument will generate project's internal transfer objects.
$ docker/sdk to-generateAlternatively Transfer Object generator can be run directly from container.
- Open container cli:
$ docker/sdk cli- Run the generator command:
$ ./bin/transfer-generate -c ./examples/config/transfer-generator/generator.config.ymlor the same by composer:
$ composer transfer-generate -- -c ./examples/config/transfer-generator/generator.config.ymlThe Transfer Object Bulk generator can be run as:
$ docker/sdk to-generate-bulk [BULK]where [BULK] is a path to the configuration bulk file.
Note
Internally project uses bulk file located at ./var/config/config.list.txt running the command above without argument will fallback to the internal project bulk file.
Alternatively Transfer Object Bulk generator can be run directly from container:
- Open container cli:
$ docker/sdk cli- Run the generator command:
$ ./bin/transfer-generate-bulk -b ./var/config/config.list.txtor the same by composer:
$ composer composer transfer-generate-bulk -- -b ./var/config/config.list.txtTo see how the Definition generator works, please run command bellow:
$ docker/sdk df-generateAlternatively Definition generator can be run directly from container:
- Open container cli:
$ docker/sdk cli- Run the generator command:
$ ./bin/definition-generateor the same by composer:
$ composer definition-generateThe Transfer Object generator might fail in the middle showing the error message. The process is successful when all Transfer Objects are generated.
The Transfer Objects are generated on the directory {path-to-transfer-object-directory}/_tmp/{uuid} preventing breaking the application on failure. In case of validation error, the temporary directory is automatically deleted.
Caution
In case of critical errors the temporary directory migh not be deleted.
Each Transfer Objects' includes doc-block with path to the definition file:
/**
* Specification:
* - Class is automatically generated based on a definition file.
* - To modify it, please update the corresponding definition file and run the generator again.
*
* Note: Do not manually edit this file, as changes will be overwritten.
*
* @see /doc/samples/config/transfer-generator/definition/customer.transfer.yml Definition file path.
*/It helps to find faster the necessary definition file.
Note
Xdebug is disabled by default.
To enable Xdebug, execute:
$ docker/sdk -x startTo enable Xdebug profiler, execute:
$ docker/sdk -xp startAlternatively Xdebug mode can be managed by .env
XDEBUG_MODE=offwith following
$ docker/sdk start