Skip to content

Commit 942d45f

Browse files
authored
Update README.md
1 parent 3ccd1fe commit 942d45f

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

README.md

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,53 @@
1-
# git-version-strategy
2-
A custom version strategy that uses the current Git commit short-hash as the version identifier.
1+
# Symfony asset versioning based on Git
2+
This is a small Symfony bundle that implements a custom version strategy which uses the current Git commit short-hash as the version identifier.
3+
4+
This will turn the URL of your assets from this:
5+
```
6+
/css/style.css
7+
```
8+
to
9+
```
10+
/css/styles.css?v=b4703f8
11+
```
12+
13+
This will ensure that you assets always match the current version of your project by eliminating browser caching issues.
14+
15+
---
16+
17+
## Getting started
18+
19+
To get started, add the bundle to your project using Composer, like so:
20+
```bash
21+
composer require emileperron/git-version-strategy-bundle
22+
```
23+
24+
Then, in your `config/bundles.php` file, include the bundle like so:
25+
```php
26+
<?php
27+
28+
return [
29+
// ...
30+
Emileperron\GitVersionStrategyBundle\EmileperronGitVersionStrategyBundle::class => ['all' => true],
31+
];
32+
```
33+
34+
Once that's done, you should be all set!
35+
The bundle automatically updates the configuration for `framework.assets.version_strategy` to use the `GitVersionStrategy`.
36+
37+
---
38+
39+
## Manual configuration of the VersionStrategy
40+
41+
If for some reason the configuration is not set automatically, which can happen if another bundle also changes this configuration, define the following configuration in your `config/packages/framework.yaml`:
42+
```yaml
43+
44+
framework:
45+
assets:
46+
version_strategy: 'Emileperron\GitVersionStrategyBundle\Asset\GitVersionStrategy'
47+
```
48+
49+
---
50+
51+
## Safe mode, execution operator and `shell_exec()`
52+
53+
This bundle uses the [Execution Operator](https://www.php.net/manual/en/language.operators.execution.php) in order to get the current commit's hash. It is important to note that this **will not work** when [safe mode](https://www.php.net/manual/en/ini.sect.safe-mode.php#ini.safe-mode) is enabled or [shell_exec()](https://www.php.net/manual/en/function.shell-exec.php) is disabled.

0 commit comments

Comments
 (0)