Skip to content
This repository has been archived by the owner on Nov 8, 2020. It is now read-only.

Commit

Permalink
Update to Silex 2, PHP 7.0
Browse files Browse the repository at this point in the history
* Merged all documentation in to README.md
* Renamed license file for Github auto-detect
* Removed old vendors files
* Added PHPCS for PSR-2 compliance
* Added new tests for Twig provider
* Added new tests for testing defaults
  • Loading branch information
mheap committed Oct 10, 2017
1 parent e0734a5 commit 53c2b43
Show file tree
Hide file tree
Showing 14 changed files with 168 additions and 2,043 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
vendor/
composer.phar
composer.phar
composer.lock
10 changes: 2 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
language: php
sudo: false

before_script: composer install --dev --prefer-source
before_script: composer install

php:
- 5.6
- 7.0
- hhvm

matrix:
allow_failures:
- php: 7.0
- php: hhvm
- 7.1
3 changes: 2 additions & 1 deletion MIT-LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2011 Sven Eisenschmidt <[email protected]>
Copyright (c) 2017 Michael Heap <[email protected]>
Sven Eisenschmidt <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
75 changes: 56 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,68 @@
Silex-Gravatar
================
# Silex-Markdown

[![Build Status](https://secure.travis-ci.org/mheap/Silex-Gravatar.png?branch=master)](http://travis-ci.org/mheap/Silex-Gravatar)

Installation
------------
### Requirements

Create a composer.json in your projects root-directory::
This extension only works with *PHP 7.1+* and *Silex 2*.
[Version 1.1.0](https://github.com/mheap/Silex-Gravater/releases/tag/1.1.0) is compatible
with Silex 1.

{
"require": {
"mheap/Silex-Gravatar": "1.*"
}
}
### Installation

and run::
Install with composer:

curl -s http://getcomposer.org/installer | php
php composer.phar install
```bash
composer require mheap/silex-gravatar
```

### Usage

More Information
----------------
First, you need to register the Gravatar extension. All of the options shown are optional.

Read the documentation files under */doc*.
```php
$app->register(new SilexExtension\GravatarExtension(), array(
'gravatar.cache_dir' => sys_get_temp_dir() . '/gravatar',
'gravatar.cache_ttl' => 240, // 240 seconds
'gravatar.options' => array(
'size' => 100,
'rating' => Gravatar\Service::RATING_G,
'secure' => true,
'default' => Gravatar\Service::DEFAULT_404,
'force_default' => true
)
));
```

License
-------
To fetch a Gravatar URL, use `$app['gravatar']`:

'Silex-Gravatar' is licensed under the MIT license.
```php
$app->get('/', function() use($app) {
return $app['gravatar']->get('[email protected]');
});
```

If you're using Twig via `Silex\Provider\TwigServiceProvider()`, a `gravatar` function will
be automatically registered for you. This allows you do do the following:

```twig
{% if gravatar_exist('[email protected]') %}
Gravatar found
{% endif %}
<img src="{{ gravatar('[email protected]', {'size': 50}) }}" />
```

### Available configuration options

The *GravatarExtension* provides access to the Gravatar web service
through Sven Eisenschmidts's `Gravatar <https://github.com/fate/Gravatar-php>`_
library.

* **gravatar.cache_dir** (optional): A directory to cache the direct web service calls to gravatar.com
* **gravatar.cache_ttl** (optional): The time how long a cache entry will live, defaults to 360 seconds
* **gravatar.options** (optional): An associative array of arguments for the [Gravatar\\Service class](https://github.com/sveneisenschmidt/gravatar-php/blob/master/src/Gravatar/Service.php#L84-L90)

### Running the tests

There are no external dependencies for this library. Just `composer install` then run `./vendor/bin/phpunit`
2 changes: 0 additions & 2 deletions bin/travis-init.sh

This file was deleted.

13 changes: 7 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,21 @@
}
],
"require": {
"php": ">=5.3.0",
"mheap/gravatar-php": "1.0.0"
"php": ">=7.0",
"mheap/gravatar-php": "^2.0"
},
"require-dev": {
"silex/silex": "1.*",
"silex/silex": "2.*",
"twig/twig": ">=1.2.0",
"phpunit/phpunit": "^5.4"
"phpunit/phpunit": "^6",
"squizlabs/php_codesniffer": "^3.1"
},
"suggest": {
"twig/twig": ">=1.2.0"
},
"autoload": {
"psr-0": {
"SilexGravatar": "src"
"psr-4": {
"SilexGravatar\\": "src"
}
}
}
Loading

0 comments on commit 53c2b43

Please sign in to comment.