Download the PHP package 20steps/versioning-bundle without Composer
On this page you can find all versions of the php package 20steps/versioning-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download 20steps/versioning-bundle
More information about 20steps/versioning-bundle
Files in 20steps/versioning-bundle
Package versioning-bundle
Short Description Symfony2|3 application versioning, simple console command to manage version (with handlers e.g. git tag) of your application using Semantic Versioning 2.0.0 recomendations
License MIT
Homepage https://github.com/shivas/versioning-bundle
Informations about the package versioning-bundle
versioning-bundle
Simple way to version your Symfony2 application.
What it is:
- Adds additional parameter to your parameters.yml file and keeps it inline with your current application version.
- Basic Version handlers implemented for manual and git tag versioning
- Easy to extend with new handlers for different SCM's or needs
- Uses Semantic Versioning 2.0.0 recommendations using https://github.com/herrera-io/php-version library
- Uses Symfony console component to create command, can be easily integrated with Capifony to update version on every deployment
Purpose:
To have parameter in your Symfony2 application with current version of application for various needs:
- Display in frontend
- Display in backend
- Anything you can come up with
Handlers implemented:
- ParameterHandler (to manage version manually using app:version:bump command)
- GitRepositoryHandler (git tag describe hangler to automaticly update version looking at git tags)
- InitialVersionHandler (just returns default initial version 0.1.0)
Install
run composer.phar update
Add bundle to your AppKernel
run in console:
Default configuration
Default configuration of bundle looks like this:
That means in the parameters file the application_version
variable will be created and updated on every bump of version, you can change the name to anything you want by writing that in your config.yml file.
You may also specify a file other than parameters.yml
if you would like to use a custom file. If so, make sure to import it in your config.yml file - you may want to use ignore_errors
on the import
to avoid issues if the file does not yet exist.
Git Handler
Git handler works only when you have atleast one TAG in your repository, and all TAGS used for versioning should follow SemVer 2.0.0 notation with exception, that git handler allows letter "v" or "V" to be used in your tags, e.g. v1.0.0
Application version from git tag are extracted in following fashion:
- v or V is stripped away
- if commit sha matches last tag sha then tag is converted to version as is
- if commit sha differs from last tag sha then following happens:
- tag is parsed as version
- prerelease part of SemVer is added with following data: "-dev.abcdefa"
- where prerelease part "dev" means that version is not tagged and is "dev" stable, and last part is commit sha
This is default behavior and can be easily changed anyway you want (later on that)
Displaying version
To display version for example in page title you can add following to your config.yml:
And then, in your Twig layout display it as global variable:
Alternatively, if you want to display version automatically without having to bump it first, set config.yml
to :
And then, in your Twig layout:
The downside is the app version will be computed every time a twig layout is loaded, even if the variable is not used in the template. However, it could be useful if you have rapid succession of new versions or if you fear to forget a version bump.
Adding own handlers
It's easy, write a class that implements HandlerInterface:
For example, lets modify how git handler adds prerelease data to version if tag is outdated, instead just add "build" part with git commit sha. We gonna reuse big part of git handler and just override method for metadata handling:
Add handler to container using your services file (xml in my case):
Take a note on priority attribute, it should be more than 0 if you want to override default git handler as it's default value is 0.
Run in console
And notice your new handler is above old one:
So, next time you execute version bump, your custom git handler will take care for your version building.
Make Composer bump your version on install
Add script handler
to your composer.json file to invoke it on post-install-cmd. Make sure it is above clearCache, it may look like this:
Capifony task for version bump
Add following to your recipe
Capistrano v3 task for version bump
Add following to your recipe
Good luck versioning your project.
Contributions for different SCM's and etc are welcome, use pull request.
All versions of versioning-bundle with dependencies
herrera-io/version Version ~1.0
symfony/symfony Version ~2.8|~3.0
symfony/process Version ~2.2|~3.0