2017 © Pedro Peláez
 

library genderize-io-bundle

Integrates GenderizerIoClient library into Symfony

image

javihgil/genderize-io-bundle

Integrates GenderizerIoClient library into Symfony

  • Thursday, December 21, 2017
  • by javihgil
  • Repository
  • 1 Watchers
  • 1 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 1 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

GenderizeIoBundle

This bundle integrates GenderizeIoClient into Symfony Projects., (*1)

Install

  1. Install package with composer:
composer require javihgil/genderize-io-bundle
  1. Add bundle to appKernel.php:
$bundles = array( 
    ...
    new Jhg\GenderizeIoBundle\GenderizeIoBundle()
);

Configure

Configuration is not required (for the free version), but if you have an api key, you can use the simplest configuration:, (*2)

genderize_io:   
   api_key: 'API_KEY_HERE'

For more extended configuration, for ex. caching, you can use the following:, (*3)

genderize_io:
   endpoint: "http://api.genderize.io/"
   api_key: 'API_KEY_HERE'
   cache: true
   cache_expiry_time: 7776000 # 90 days
   cache_handler: 'genderize_io.cache_handler_doctrine' # default

Usage from a controller

/** @var Jhg\GenderizeIoClient\Model\Name $name */
$name = $this->get('genderizer')->recognize('John');
echo $name->getGender();
// shows "male"

Usage from twig

{{ 'John' | gender }}
{# paints "male" #}

{{ 'John' | genderInCountry('gb') }}
{# paints "male" #}

{{ 'John' | genderInLanguage('en') }}
{# paints "male" #}

{# consider using default filter after gender function for unknown cases #}
{{ 'Unknown Name' | gender | default('no genre') }}
{# paints "no gerne" #}    

{% if isMale('John') %}
    {# do something for male #}
{% else isFemale('John') %}
    {# do something for male #}
{% else %}
    {# do something for unknown cases #}
{% endif %}

The Versions

21/12 2017

dev-master

9999999-dev

Integrates GenderizerIoClient library into Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony client genderize.io

21/12 2017

v1.1.0

1.1.0.0

Integrates GenderizerIoClient library into Symfony

  Sources   Download

MIT

The Requires

 

The Development Requires

php symfony client genderize.io