tarioch/eveapi-fetcher-bundle

Provides automatic EVE Online Api fetching to your Symfony2 project.


Keywords
symfony, EVE Online, EVE API
License
MIT

Documentation

EVE Api Fetcher Bundle

Latest Stable Version Build Status Scrutinizer Quality Score SensioLabsInsight

Copyright (C) 2013 - 2015 by Patrick Ruckstuhl All rights reserved.

Symfony bundle for automatic fetching of the EVE Online API, heavily inspired by Yapeal and makes use of PhealNG

LICENSE

EVE Api Fetcher Bundle is licensed under a MIT style license, see LICENSE.txt for further information

Dependencies

INSTALLATION

First you need to add tarioch/eveapi-fetcher-bundle to composer.json:

{
   "require": {
        "tarioch/eveapi-fetcher-bundle": "dev-master"
    }
}

Bundles

You have to add the following Bundles to your AppKernel.php:

// app/AppKernel.php
//...
class AppKernel extends Kernel
{
    //...
    public function registerBundles()
    {
        $bundles = array(
            ...
            new JMS\DiExtraBundle\JMSDiExtraBundle($this),
            new JMS\AopBundle\JMSAopBundle(),
            new Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle(),
            new Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
            new Mmoreram\GearmanBundle\GearmanBundle(),
            new Tarioch\PhealBundle\TariochPhealBundle(),
            new Tarioch\EveapiFetcherBundle\TariochEveapiFetcherBundle(),
        );
        //...

        return $bundles;
    }
    //...
}

Configuration

You have to add the following things to your config

  • Annotation parsing
  • Entity manager
  • Doctrine migrations
  • Gearman
// app/config/config.yml
// ...
jms_di_extra:
    locations:
        all_bundles: false
        bundles: [TariochPhealBundle, TariochEveapiFetcherBundle]

doctrine:
    dbal:
        connections:
                eveapi:
                        driver:   "%database_driver%"
                        host:     "%database_host%"
                        port:     "%database_port%"
                        dbname:   "%database_eveapi_name%"
                        user:     "%database_user%"
                        password: "%database_password%"
                        charset:  UTF8
                        mapping_types:
                                enum: string

    orm:
        entity_managers:
                eveapi:
                        connection: eveapi
                        mappings:
                                TariochEveapiFetcherBundle: ~

doctrine_migrations:
    # workaround, see http://stackoverflow.com/questions/17066670/symfony2-change-migration-directory
    dir_name: '%kernel.root_dir%/../vendor/tarioch/eveapi-fetcher-bundle/Tarioch/EveapiFetcherBundle/DoctrineMigrations'

doctrine_cache:
    providers:
        gearman_cache:
            type: file_system
            namespace: doctrine_cache.ns.gearman

gearman:
    bundles:
        TariochEveapiFetcherBundle:
            name: TariochEveapiFetcherBundle
            active: true
            include:
                - Component/Worker
    defaults:
        method: doNormal
        iterations: 50
        callbacks: false
        job_prefix: null
        generate_unique_key: true
        workers_name_prepend_namespace: false

    servers:
        localhost:
            host: 127.0.0.1
            port: 4730

tarioch_pheal:
    user_agent: yourname@example.tld

Database

For getting the correct database schema, run

php app/console doctrine:migrations:migrate --em=eveapi

Running

The best way to run this is to have a minutely cron job that schedules missing api calls and use supervisord for actually running the workers.

Cronjob

* * * * * su www-data -c '/usr/bin/php /path/to/app/console eve:api:schedule --env=prod'

Supervisord

http://supervisord.org

[program:evetool]
process_name=evetool%(process_num)s
command=/usr/bin/php /path/to/app/console gearman:worker:execute TariochEveapiFetcherEveWorker --env=prod --no-interaction
numprocs=10
autostart=true
autorestart=true
user=www-data

Getting started

Simply insert a key into the table apiKey and all available and implemented api data will be fetched.

Help

Feel free to open an issue if you have an issues or questions.