diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d0954db --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +._* +.~lock.* +.buildpath +.DS_Store +.idea +.project +.settings +Thumbs.db +phpunit.xml +tmp/ +vendor/ +composer.lock +composer.phar \ No newline at end of file diff --git a/Module.php b/Module.php new file mode 100644 index 0000000..2eefb7d --- /dev/null +++ b/Module.php @@ -0,0 +1,50 @@ + + * @licence MIT + */ +class Module implements Feature\AutoloaderProviderInterface, Feature\ConfigProviderInterface +{ + /** + * {@inheritDoc} + */ + public function getAutoloaderConfig() + { + return array( + 'Zend\Loader\StandardAutoloader' => array( + 'namespaces' => array( + __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, + ), + ), + ); + } + + /** + * {@inheritDoc} + */ + public function getConfig() + { + return include __DIR__ . '/config/module.config.php'; + } +} diff --git a/README.md b/README.md index 39abc29..5b0bf89 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,34 @@ -zfr-mailchimp-module -==================== +ZfrMailChimpModule +================== + +ZfrMailChimpModule is a Zend Framework 2 module based on [ZfrMailChimp](https://github.com/zf-fr/zfr-mailchimp). + +Requirements +------------ +* PHP 5.3 +* [Zend Framework 2](https://github.com/zendframework/zf2) +* [ZfrMailChimp](https://github.com/zf-fr/zfr-mailchimp) + +Installation +------------ + +We recommend you to use Composer to install ZfrMailChimp: + +```sh +php composer.phar require zfr/zfr-mailchimp-module:dev-master +```sh + +Enable ZfrMailChimpModule in your `application.config.php`, then copy-paste the file `zfr_mailchimp.local.php.dist` (that +you can find in the `config` folder of the module) to your `autoload` folder (don't forget to remove the .dist at +the end!). + +Usage +----- + +The module registers the MailChimpClient to the ZF 2 service manager. You can therefore get it like this: + +```php +// If you want to client: +$mailChimpClient = $serviceManager->get('ZfrMailChimp\Client\MailChimpClient'); +``` -A Zend Framework 2 module around ZfrMailChimp diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..8bcc726 --- /dev/null +++ b/composer.json @@ -0,0 +1,34 @@ +{ + "name": "zfr/zfr-mailchimp-module", + "type": "library", + "license": "MIT", + "description" : "Zend Framework 2 module for interacting with the v2 MailChimp API, built on top of ZfrMailChimp", + "keywords": [ + "mailchimp", + "campaign", + "mail chimp", + "zf2", + "bulk email" + ], + "homepage": "https://github.com/zf-fr/zfr-mailchimp-module", + "authors": [ + { + "name": "Michaël Gallego", + "email": "mic.gallego@gmail.com", + "homepage": "http://www.michaelgallego.fr" + } + ], + "require": { + "php": ">=5.3.3", + "zendframework/zend-servicemanager": "2.*", + "zfr/zfr-mailchimp": "dev-master" + }, + "autoload": { + "psr-0": { + "ZfrMailChimpModule\\": "src/" + }, + "classmap": [ + "./" + ] + } +} diff --git a/config/module.config.php b/config/module.config.php new file mode 100644 index 0000000..47c8c57 --- /dev/null +++ b/config/module.config.php @@ -0,0 +1,25 @@ + array( + 'factories' => array( + 'ZfrMailChimp\Client\MailChimpClient' => 'ZfrMailChimpModule\Factory\MailChimpClientFactory', + ), + ), +); diff --git a/config/zfr_mailchimp.local.php.dist b/config/zfr_mailchimp.local.php.dist new file mode 100644 index 0000000..a9c977c --- /dev/null +++ b/config/zfr_mailchimp.local.php.dist @@ -0,0 +1,26 @@ + array( + /** + * Specify your MailChimp API key. You can find it on your account + */ + // 'key' => '' + ) +); diff --git a/src/ZfrMailChimpModule/Factory/Exception/RuntimeExcepti.php b/src/ZfrMailChimpModule/Factory/Exception/RuntimeExcepti.php new file mode 100644 index 0000000..0c289b2 --- /dev/null +++ b/src/ZfrMailChimpModule/Factory/Exception/RuntimeExcepti.php @@ -0,0 +1,29 @@ + + * @licence MIT + */ +class RuntimeException extends BaseRuntimeException +{ +} diff --git a/src/ZfrMailChimpModule/Factory/MailChimpClientFactory.php b/src/ZfrMailChimpModule/Factory/MailChimpClientFactory.php new file mode 100644 index 0000000..f212ee2 --- /dev/null +++ b/src/ZfrMailChimpModule/Factory/MailChimpClientFactory.php @@ -0,0 +1,38 @@ + + */ + +namespace ZfrMailChimpModule\Factory; + +use Zend\ServiceManager\FactoryInterface; +use Zend\ServiceManager\ServiceLocatorInterface; +use ZfrMailChimp\Client\MailChimpClient; + +/** + * @author Michaël Gallego + * @licence MIT + */ +class MailChimpClientFactory implements FactoryInterface +{ + /** + * {@inheritDoc} + */ + public function createService(ServiceLocatorInterface $serviceLocator) + { + $config = $serviceLocator->get('Config'); + + if (!isset($config['zfr_mailchimp'])) { + throw new Exception\RuntimeException( + 'No config was found for ZfrMailChimpModule. Did you copy the `zfr_mailchimp.local.php` file to your autoload folder?' + ); + } + + return new MailChimpClient($config['zfr_mailchimp']['key']); + } +} diff --git a/src/ZfrMailChimpModule/Version.php b/src/ZfrMailChimpModule/Version.php new file mode 100644 index 0000000..588502f --- /dev/null +++ b/src/ZfrMailChimpModule/Version.php @@ -0,0 +1,28 @@ + + * @licence MIT + */ +class Version +{ + const VERSION = '1.0.0-beta1'; +}