├── .gitignore ├── LICENSE ├── README ├── README.1.3.x ├── build.properties ├── build.xml ├── composer.json ├── composer.lock ├── docs └── examples │ ├── ComponentAnnotation │ └── example.php │ ├── ConfigurationAnnotation │ └── example.php │ ├── ErrorHandler │ ├── annotated │ │ ├── example.php │ │ └── log4php.properties │ ├── beans.xml │ └── example.php │ ├── InjectAnnotation │ └── example.php │ ├── PAGI │ ├── beans.xml │ ├── example.php │ ├── file.properties │ ├── log4php.properties │ └── run.sh │ ├── PAMI │ ├── beans.xml │ └── example.php │ ├── PhpProperties │ ├── beans.xml │ ├── example.php │ └── file.properties │ ├── PropertiesAnnotation │ ├── beans.xml │ └── example.php │ ├── RequiredAnnotation │ ├── beans.xml │ └── example.php │ ├── ResourceAnnotation │ ├── beans.xml │ └── example.php │ ├── ShutdownHandler │ ├── annotated │ │ ├── example.php │ │ └── log4php.properties │ ├── beans.xml │ └── example.php │ ├── SignalHandler │ ├── annotated │ │ ├── example.php │ │ └── log4php.properties │ ├── beans.xml │ └── example.php │ ├── SyslogHelper │ ├── beans.xml │ └── example.php │ ├── TCPClientHelper │ ├── beans.xml │ ├── example.php │ └── file.properties │ ├── TCPServerHelper │ ├── beans.xml │ ├── example.php │ └── file.properties │ ├── ValueAnnotation │ └── example.php │ ├── alias-annotations │ └── example.php │ ├── alias-xml │ ├── beans.xml │ └── example.php │ ├── alias-yaml │ ├── beans.yaml │ └── example.php │ ├── aop-annotation │ ├── beans.xml │ └── example.php │ ├── aop-global │ ├── beans.xml │ └── example.php │ ├── aop-regex │ ├── beans.xml │ └── example.php │ ├── aop │ ├── beans.xml │ └── example.php │ ├── arrays │ ├── beans.xml │ └── example.php │ ├── basic-with-phar │ ├── beans.xml │ └── example.php │ ├── basic │ ├── beans.xml │ └── example.php │ ├── bookstore │ ├── README │ ├── cli-config.php │ ├── private │ │ ├── config │ │ │ ├── application.properties │ │ │ ├── doctrine.properties │ │ │ ├── log4php.properties │ │ │ └── php.properties │ │ ├── context │ │ │ ├── beans.xml │ │ │ ├── i18n.xml │ │ │ ├── mvc.xml │ │ │ └── persistence.xml │ │ ├── i18n │ │ │ ├── books_default.properties │ │ │ └── books_es_ES.properties │ │ └── src │ │ │ └── BookStore │ │ │ ├── Aspect │ │ │ ├── Profiler.php │ │ │ └── Transactional.php │ │ │ ├── Controllers │ │ │ ├── Book.php │ │ │ ├── Exception.php │ │ │ ├── Main.php │ │ │ └── Settings.php │ │ │ ├── Domain │ │ │ ├── Entity │ │ │ │ └── Book.php │ │ │ ├── Repository │ │ │ │ ├── BookRepository.php │ │ │ │ └── Configuration.php │ │ │ └── Service │ │ │ │ ├── AbstractService.php │ │ │ │ └── Book.php │ │ │ └── ErrorHandler │ │ │ └── ErrorHandler.php │ └── public │ │ ├── bootstrap.php │ │ ├── favicon.ico │ │ ├── index.php │ │ └── views │ │ ├── createBook.phtml │ │ ├── created.phtml │ │ ├── exception.phtml │ │ ├── footer.phtml │ │ ├── header.phtml │ │ ├── home.phtml │ │ ├── layout.phtml │ │ ├── list.phtml │ │ └── main.phtml │ ├── doctrine │ ├── README │ ├── beans.xml │ ├── entities │ │ └── Person.php │ ├── example.php │ └── schema.sql │ ├── events │ ├── beans.xml │ ├── beans.yaml │ └── example.php │ ├── i18n │ ├── another_bundle_es.properties │ ├── beans.xml │ ├── default_es.properties │ └── example.php │ ├── inheritance-annotations │ └── example.php │ ├── inheritance-xml │ ├── beans.xml │ └── example.php │ ├── inheritance-yaml │ ├── beans.yaml │ └── example.php │ ├── innerBeans │ ├── beans.xml │ └── example.php │ ├── lifecycle │ ├── beans.xml │ └── example.php │ ├── log4php.properties │ ├── loggeraware │ ├── beans.xml │ └── example.php │ ├── methodInjection │ ├── beans.xml │ └── example.php │ ├── mvc-interceptors │ ├── beans.xml │ ├── controllers.xml │ ├── index.php │ ├── log4php.properties │ ├── mvc.xml │ └── views │ │ ├── view.annotated.html │ │ ├── view.exception.html │ │ ├── view.json.html │ │ └── view.some.html │ ├── mvc-smarty │ ├── annotatedControllers │ │ └── someControllers.php │ ├── beans.xml │ ├── controllers.xml │ ├── example.php │ ├── log4php.properties │ ├── mvc.xml │ └── views │ │ ├── view.annotated.tpl │ │ ├── view.exception.tpl │ │ └── view.some.tpl │ ├── mvc-twig │ ├── annotatedControllers │ │ └── someControllers.php │ ├── beans.xml │ ├── controllers.xml │ ├── example.php │ ├── log4php.properties │ ├── mvc.xml │ └── views │ │ ├── view.annotated.html │ │ ├── view.exception.html │ │ └── view.some.html │ ├── mvc │ ├── annotatedControllers │ │ └── someControllers.php │ ├── beans.xml │ ├── controllers.xml │ ├── example.php │ ├── index.php │ ├── log4php.properties │ ├── mvc.xml │ └── views │ │ ├── view.annotated.html │ │ ├── view.exception.html │ │ ├── view.json.html │ │ └── view.some.html │ ├── quickstart │ ├── aspects.xml │ ├── beans.xml │ ├── example.php │ ├── factories.xml │ ├── file.properties │ ├── handlers.php │ ├── other.properties │ └── user.properties │ ├── resources-autoload │ ├── beans.xml │ ├── example.php │ └── file.properties │ ├── resources │ ├── example.php │ └── test.zip │ ├── specialValues │ ├── beans.xml │ └── example.php │ └── yaml │ ├── beans.yaml │ ├── example.php │ ├── file.properties │ └── otherBeans.yaml ├── resources ├── checkstyle.xsl ├── cpd.xslt ├── generatePackageXml.php ├── generatePhar.php ├── pdepend.xsl ├── php.ini.example ├── phpunit_to_surefire.xslt └── pmd.xslt ├── src └── mg │ └── Ding │ ├── Annotation │ ├── Annotation.php │ ├── Collection.php │ ├── Exception │ │ └── AnnotationException.php │ └── Parser.php │ ├── Aspect │ ├── AspectDefinition.php │ ├── AspectManager.php │ ├── IAspectManagerAware.php │ ├── IAspectProvider.php │ ├── IPointcutProvider.php │ ├── Interceptor │ │ ├── AdviceDefinition.php │ │ ├── DispatcherImpl.php │ │ └── IDispatcher.php │ ├── MethodInvocation.php │ ├── PointcutDefinition.php │ └── Proxy.php │ ├── Autoloader │ └── Autoloader.php │ ├── Bean │ ├── BeanConstructorArgumentDefinition.php │ ├── BeanDefinition.php │ ├── BeanPropertyDefinition.php │ ├── Factory │ │ ├── Driver │ │ │ ├── AnnotationDiscovererDriver.php │ │ │ ├── AnnotationInitDestroyMethodDriver.php │ │ │ ├── AnnotationInjectDriver.php │ │ │ ├── AnnotationRequiredDriver.php │ │ │ ├── AnnotationResourceDriver.php │ │ │ ├── AnnotationValueDriver.php │ │ │ ├── MessageSourceDriver.php │ │ │ ├── MethodInjectionDriver.php │ │ │ ├── MvcAnnotationDriver.php │ │ │ └── PropertiesDriver.php │ │ └── Exception │ │ │ ├── BeanFactoryException.php │ │ │ └── InjectByTypeException.php │ ├── IBeanDefinitionProvider.php │ ├── IBeanNameAware.php │ ├── Lifecycle │ │ ├── BeanLifecycle.php │ │ ├── BeanLifecycleManager.php │ │ ├── IAfterAssembleListener.php │ │ ├── IAfterConfigListener.php │ │ ├── IAfterCreateListener.php │ │ ├── IAfterDefinitionListener.php │ │ ├── IBeforeAssembleListener.php │ │ ├── IBeforeCreateListener.php │ │ └── ILifecycleListener.php │ └── Provider │ │ ├── Annotation.php │ │ ├── Core.php │ │ ├── Xml.php │ │ └── Yaml.php │ ├── Cache │ ├── Exception │ │ ├── CacheException.php │ │ └── FileCacheException.php │ ├── ICache.php │ ├── Impl │ │ ├── ApcCacheImpl.php │ │ ├── DummyCacheImpl.php │ │ ├── FileCacheImpl.php │ │ ├── MemcachedCacheImpl.php │ │ └── ZendCacheImpl.php │ └── Locator │ │ └── CacheLocator.php │ ├── Container │ ├── IContainer.php │ ├── IContainerAware.php │ └── Impl │ │ └── ContainerImpl.php │ ├── Exception │ └── DingException.php │ ├── Helpers │ ├── ErrorHandler │ │ └── ErrorInfo.php │ ├── Pagi │ │ ├── PagiExtensionMapper.php │ │ └── PagiHelper.php │ ├── Pami │ │ ├── IPamiEventHandler.php │ │ └── PamiHelper.php │ ├── Properties │ │ ├── IPropertiesHolder.php │ │ └── PropertiesHelper.php │ ├── Syslog │ │ └── SyslogHelper.php │ └── Tcp │ │ ├── Exception │ │ └── TcpException.php │ │ ├── ITcpClientHandler.php │ │ ├── ITcpServerHandler.php │ │ ├── TcpClientHelper.php │ │ ├── TcpPeer.php │ │ └── TcpServerHelper.php │ ├── HttpSession │ └── HttpSession.php │ ├── Logger │ └── ILoggerAware.php │ ├── MessageSource │ ├── IMessageSource.php │ ├── IMessageSourceAware.php │ └── Impl │ │ └── MessageSourceImpl.php │ ├── Mvc │ ├── Action.php │ ├── DispatchInfo.php │ ├── Dispatcher.php │ ├── Exception │ │ └── MvcException.php │ ├── ForwardModelAndView.php │ ├── Http │ │ ├── HttpAction.php │ │ ├── HttpDispatcher.php │ │ ├── HttpExceptionMapper.php │ │ ├── HttpFrontController.php │ │ ├── HttpInterceptor.php │ │ ├── HttpUrlMapper.php │ │ ├── HttpView.php │ │ ├── HttpViewRender.php │ │ ├── HttpViewResolver.php │ │ ├── SmartyViewRender.php │ │ └── TwigViewRender.php │ ├── IHandlerInterceptor.php │ ├── IMapper.php │ ├── IViewRender.php │ ├── IViewResolver.php │ ├── ModelAndView.php │ ├── RedirectModelAndView.php │ └── View.php │ ├── Reflection │ ├── IReflectionFactory.php │ ├── IReflectionFactoryAware.php │ └── ReflectionFactory.php │ └── Resource │ ├── Exception │ └── ResourceException.php │ ├── IResource.php │ ├── IResourceLoader.php │ ├── IResourceLoaderAware.php │ └── Impl │ ├── FilesystemResource.php │ ├── IncludePathResource.php │ └── URLResource.php └── test ├── annotation └── Test_Annotations.php ├── aop ├── annotation │ └── Test_Annotation_AOP.php ├── cache │ └── Test_Cache_AOP.php ├── dispatcher │ └── Test_Dispatcher.php ├── proxy │ └── Test_Proxy.php ├── xml │ └── Test_XML_AOP.php └── yaml │ └── Test_YAML_AOP.php ├── autoloader └── Test_Autoloader.php ├── aware ├── Test_AspectManager_Aware.php ├── Test_BeanName_Aware.php ├── Test_Container_Aware.php ├── Test_Lifecycle_Aware.php ├── Test_Logger_Aware.php ├── Test_MessageSource_Aware.php └── Test_ResourceLoader_Aware.php ├── bootstrap.php ├── cache ├── apc │ ├── Test_IoC_Annotation_Cache_APC.php │ └── Test_IoC_Cache_APC.php ├── dummy │ └── Test_Cache_Dummy.php ├── file │ ├── Test_IoC_Annotation_Cache_File.php │ └── Test_IoC_Cache_File.php ├── locator │ └── Test_Cache_Locator.php ├── memcached │ ├── Test_IoC_Annotation_Cache_Memcached.php │ └── Test_IoC_Cache_Memcached.php └── zfcache │ ├── Test_IoC_Annotation_Cache_ZF.php │ └── Test_IoC_Cache_ZF.php ├── container └── Test_Container.php ├── error └── Test_Error.php ├── event └── Test_Event.php ├── filter ├── xml │ └── Test_XML_Filter.php └── yaml │ └── Test_YAML_Filter.php ├── httpsession └── Test_HttpSession.php ├── i18n └── Test_i18n.php ├── ioc ├── annotation │ ├── Test_AnnotationNamespace_classes.php │ ├── Test_Annotation_IoC.php │ ├── donotscan │ ├── donotscan2.notaphp │ └── somesubdir │ │ └── emptyclassfile.php ├── xml │ └── Test_XML_IoC.php └── yaml │ └── Test_YAML_IoC.php ├── mvc ├── Test_HttpDispatcher.php ├── Test_HttpFrontController.php ├── Test_HttpView.php ├── Test_HttpViewResolver.php └── Test_ModelAndView.php ├── phpunit.xml ├── reflection └── Test_Reflection.php ├── resources-feature ├── Test_Filesystem_Resource.php ├── Test_IncludePath_Resource.php └── Test_URL_Resource.php ├── resources ├── abundle_default.properties ├── abundle_es_AR.properties ├── aop-annotation-simple.xml ├── aop-dispatcher.xml ├── aop-proxy.xml ├── aop-xml-simple.xml ├── aop-yaml-simple.yaml ├── container.xml ├── container.yaml ├── errorBeans.xml ├── events.xml ├── events.yaml ├── filter-xml-simple-holder-string.xml ├── filter-xml-simple-holder.xml ├── filter-xml-simple.xml ├── filter-yaml-file.yaml ├── filter.properties ├── frontcontroller.xml ├── frontcontroller2.xml ├── frontcontroller3.xml ├── i18n.xml ├── inject.xml ├── inject.yaml ├── ioc-xml-invalid.xml ├── ioc-xml-simple.xml ├── ioc-yaml-invalid.yaml ├── ioc-yaml-simple.yaml ├── log4php.properties ├── moreBeans │ ├── moreBeans.xml │ └── moreBeans.yaml ├── mvc.xml ├── resource-autoload.xml ├── shutdownBeans.xml ├── signalBeans.xml ├── someOtherFile.xml ├── someOtherFile.yaml ├── someresource.txt ├── syslog.xml ├── tcpclient.xml ├── tcpclientmock.xml ├── tcpserver.xml └── views │ ├── view.fwd.html │ ├── view.index.html │ ├── view.some.html │ ├── view.someException.html │ ├── view.someOtherException.html │ ├── view.someSmarty.tpl │ └── view.someTwig.html ├── shutdown └── Test_Shutdown.php ├── signal └── Test_Signal.php ├── syslog └── Test_Syslog.php └── tcp ├── Test_TCP_Client.php ├── Test_TCP_Mock.php ├── Test_TCP_Peer.php └── Test_TCP_Server.php /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/* 2 | .buildpath 3 | .settings 4 | .project 5 | log.log 6 | build 7 | bookstore.sqlite 8 | resources/php.ini 9 | 10 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "marcelog/ding", 3 | "type": "framework", 4 | "description": "PHP Dependency Injection based on Spring(tm), with Aspect Oriented Programming, MVC", 5 | "keywords": ["dependency", "injection", "di", "aop", "aspect", "event", "mvc", "tcp", "container", "bean", "jsr", "spring", "xml", "yaml", "annotation"], 6 | "homepage": "http://marcelog.github.com/Ding", 7 | "license": "Apache2", 8 | "authors": [ 9 | { 10 | "name": "Marcelo Gornstein", 11 | "email": "marcelog@gmail.com", 12 | "homepage": "http://marcelog.github.com", 13 | "role": "Developer" 14 | } 15 | ], 16 | "repositories": [ 17 | { 18 | "type": "pear", 19 | "url": "http://pear.apache.org/log4php/" 20 | }], 21 | "autoload": { 22 | "psr-0": { 23 | "Ding": "src/mg" 24 | } 25 | }, 26 | "require": { 27 | "php": ">=5.3.3", 28 | "apache/log4php": "2.3.0" 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", 5 | "This file is @generated automatically" 6 | ], 7 | "hash": "ba6087e6a7372960fd986d04c741f64e", 8 | "packages": [ 9 | { 10 | "name": "apache/log4php", 11 | "version": "2.3.0", 12 | "source": { 13 | "type": "git", 14 | "url": "https://git-wip-us.apache.org/repos/asf/logging-log4php.git", 15 | "reference": "8c6df2481cd68d0d211d38f700406c5f0a9de0c2" 16 | }, 17 | "require": { 18 | "php": ">=5.2.7" 19 | }, 20 | "type": "library", 21 | "autoload": { 22 | "classmap": [ 23 | "src/main/php/" 24 | ] 25 | }, 26 | "notification-url": "https://packagist.org/downloads/", 27 | "license": [ 28 | "Apache-2.0" 29 | ], 30 | "description": "A versatile logging framework for PHP", 31 | "homepage": "http://logging.apache.org/log4php/", 32 | "keywords": [ 33 | "log", 34 | "logging", 35 | "php" 36 | ], 37 | "time": "2012-10-26 09:13:25" 38 | } 39 | ], 40 | "packages-dev": [], 41 | "aliases": [], 42 | "minimum-stability": "stable", 43 | "stability-flags": [], 44 | "prefer-stable": false, 45 | "platform": { 46 | "php": ">=5.3.3" 47 | }, 48 | "platform-dev": [] 49 | } 50 | -------------------------------------------------------------------------------- /docs/examples/ErrorHandler/annotated/log4php.properties: -------------------------------------------------------------------------------- 1 | log4php.appender.default.layout = LoggerLayoutSimple 2 | log4php.appender.default = LoggerAppenderDailyFile 3 | log4php.appender.default.file = ./log.log 4 | log4php.rootLogger = INFO, default 5 | log4php.logger.Ding = DEBUG, default 6 | log4php.additivity.Ding = "false" 7 | -------------------------------------------------------------------------------- /docs/examples/ErrorHandler/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/examples/ErrorHandler/example.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://marcelog.github.com/ Apache License 2.0 12 | * @link http://marcelog.github.com/ 13 | * 14 | * Copyright 2011 Marcelo Gornstein 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | */ 29 | ini_set( 30 | 'include_path', 31 | implode( 32 | PATH_SEPARATOR, 33 | array( 34 | implode(DIRECTORY_SEPARATOR, array('..', '..', '..', 'src', 'mg')), 35 | ini_get('include_path'), 36 | ) 37 | ) 38 | ); 39 | 40 | require_once 'Ding/Autoloader/Autoloader.php'; // Include ding autoloader. 41 | \Ding\Autoloader\Autoloader::register(); // Call autoloader register for ding autoloader. 42 | use Ding\Container\Impl\ContainerImpl; 43 | use Ding\Helpers\ErrorHandler\ErrorInfo; 44 | 45 | error_reporting(E_ALL); 46 | ini_set('display_errorrs', 1); 47 | 48 | /** 49 | * This is our bean. 50 | */ 51 | class MyErrorHandler 52 | { 53 | public function onDingError(ErrorInfo $error) 54 | { 55 | echo "This is your custom error handler: $error\n"; 56 | } 57 | 58 | public function __construct() 59 | { 60 | } 61 | } 62 | 63 | // Here you configure the container, its subcomponents, drivers, etc. 64 | $properties = array( 65 | 'ding' => array( 66 | 'log4php.properties' => __DIR__ . '/../log4php.properties', 67 | 'factory' => array( 68 | 'bdef' => array( // Both of these drivers are optional. They are both included just for the thrill of it. 69 | 'xml' => array('filename' => 'beans.xml'), 70 | ), 71 | ), 72 | ) 73 | ); 74 | $container = ContainerImpl::getInstance($properties); 75 | $excuse = $notExistant; 76 | -------------------------------------------------------------------------------- /docs/examples/PAGI/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | resource://includepath://file.properties 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | ${app1.num} 16 | 17 | 18 | 19 | 20 | 21 | ${app2.num} 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | ${log4php.properties} 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | ${log4php.properties} 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | ${log4php.properties} 55 | 56 | 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /docs/examples/PAGI/file.properties: -------------------------------------------------------------------------------- 1 | log4php.properties=log4php.properties 2 | app1.num=1 3 | app2.num=2 4 | 5 | -------------------------------------------------------------------------------- /docs/examples/PAGI/log4php.properties: -------------------------------------------------------------------------------- 1 | log4php.appender.default.layout = LoggerLayoutSimple 2 | log4php.appender.default = LoggerAppenderDailyFile 3 | log4php.appender.default.file = /tmp/Ding/log.log 4 | log4php.rootLogger = INFO, default 5 | log4php.logger.Ding = DEBUG, default 6 | log4php.additivity.Ding = "false" 7 | -------------------------------------------------------------------------------- /docs/examples/PAGI/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ################################################################################ 3 | # Sample application to run from your dialplan. 4 | ################################################################################ 5 | 6 | # Location for your log4php.properties 7 | export log4php_properties=/tmp/log4php.properties 8 | export beans_xml_dir=/tmp 9 | 10 | # Make sure this is in the include path. 11 | export PAGIBootstrap=example.php 12 | 13 | # Your copy of PAGI, where src/ is. 14 | pagi=/export/users/marcelog/src/sts/PAGI 15 | ding=/export/users/marcelog/src/sts/Ding 16 | 17 | # Your copy of log4php (optional) 18 | log4php=/export/users/marcelog 19 | 20 | # PHP to run and options 21 | php=/usr/php-5.3/bin/php 22 | phpoptions="-d include_path=${log4php}:${pagi}/src/mg:${ding}/src/mg:${ding}/docs/examples/PAGI" 23 | 24 | # Standard.. the idea is to have a common launcher. 25 | launcher=${ding}/src/mg/Ding/Helpers/Pagi/PagiHelper.php 26 | 27 | # Go! 28 | ${php} ${phpoptions} ${launcher} 29 | 30 | -------------------------------------------------------------------------------- /docs/examples/PAMI/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${ami.user} 5 | ${ami.pass} 6 | ${ami.host} 7 | ${ami.port} 8 | ${ami.connect_timeout} 9 | ${ami.read_timeout} 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /docs/examples/PhpProperties/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | file://file.properties 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /docs/examples/PhpProperties/file.properties: -------------------------------------------------------------------------------- 1 | php.date.timezone = Navajo 2 | -------------------------------------------------------------------------------- /docs/examples/PropertiesAnnotation/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/examples/RequiredAnnotation/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${user.name} 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/examples/ResourceAnnotation/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/examples/ShutdownHandler/annotated/log4php.properties: -------------------------------------------------------------------------------- 1 | log4php.appender.default.layout = LoggerLayoutSimple 2 | log4php.appender.default = LoggerAppenderDailyFile 3 | log4php.appender.default.file = ./log.log 4 | log4php.rootLogger = INFO, default 5 | log4php.logger.Ding = DEBUG, default 6 | log4php.additivity.Ding = "false" 7 | -------------------------------------------------------------------------------- /docs/examples/ShutdownHandler/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/examples/SignalHandler/annotated/log4php.properties: -------------------------------------------------------------------------------- 1 | log4php.appender.default.layout = LoggerLayoutSimple 2 | log4php.appender.default = LoggerAppenderDailyFile 3 | log4php.appender.default.file = ./log.log 4 | log4php.rootLogger = INFO, default 5 | log4php.logger.Ding = DEBUG, default 6 | log4php.additivity.Ding = "false" 7 | -------------------------------------------------------------------------------- /docs/examples/SignalHandler/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /docs/examples/SyslogHelper/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${ident} 5 | ${options} 6 | ${facility} 7 | 8 | -------------------------------------------------------------------------------- /docs/examples/SyslogHelper/example.php: -------------------------------------------------------------------------------- 1 | 11 | * @license http://marcelog.github.com/ Apache License 2.0 12 | * @link http://marcelog.github.com/ 13 | * 14 | * Copyright 2011 Marcelo Gornstein 15 | * 16 | * Licensed under the Apache License, Version 2.0 (the "License"); 17 | * you may not use this file except in compliance with the License. 18 | * You may obtain a copy of the License at 19 | * 20 | * http://www.apache.org/licenses/LICENSE-2.0 21 | * 22 | * Unless required by applicable law or agreed to in writing, software 23 | * distributed under the License is distributed on an "AS IS" BASIS, 24 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 25 | * See the License for the specific language governing permissions and 26 | * limitations under the License. 27 | * 28 | */ 29 | ini_set( 30 | 'include_path', 31 | implode( 32 | PATH_SEPARATOR, 33 | array( 34 | implode(DIRECTORY_SEPARATOR, array('..', '..', '..', 'src', 'mg')), 35 | ini_get('include_path'), 36 | ) 37 | ) 38 | ); 39 | 40 | require_once 'Ding/Autoloader/Autoloader.php'; // Include ding autoloader. 41 | \Ding\Autoloader\Autoloader::register(); // Call autoloader register for ding autoloader. 42 | 43 | use Ding\Container\Impl\ContainerImpl; 44 | 45 | $properties = array( 46 | 'ding' => array( 47 | 'log4php.properties' => __DIR__ . '/../log4php.properties', 48 | 'factory' => array( 49 | 'bdef' => array('xml' => array('filename' => 'beans.xml')), 50 | 'properties' => array( 51 | 'ident' => 'ident', 52 | 'options' => LOG_PID | LOG_ODELAY, 53 | 'facility' => LOG_USER 54 | ) 55 | ), 56 | 'cache' => array( 57 | 'proxy' => array('impl' => 'dummy', 'directory' => '/tmp/Ding/proxy'), 58 | 'bdef' => array('impl' => 'dummy', 'directory' => '/tmp/Ding/bdef'), 59 | 'beans' => array('impl' => 'dummy') 60 | ) 61 | ) 62 | ); 63 | $a = ContainerImpl::getInstance($properties); 64 | $syslog = $a->getBean('Syslog'); 65 | $syslog->emerg('some log'); 66 | $syslog->alert('some log'); 67 | $syslog->critical('some log'); 68 | $syslog->error('some log'); 69 | $syslog->warning('some log'); 70 | $syslog->notice('some log'); 71 | $syslog->info('some log'); 72 | $syslog->debug('some log'); 73 | -------------------------------------------------------------------------------- /docs/examples/TCPClientHelper/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | resource://includepath://file.properties 7 | 8 | 9 | 10 | 11 | 12 | ${tcp.cto} 13 | 14 | 15 | ${tcp.rto} 16 | 17 | 18 | ${tcp.rlen} 19 | 20 | 21 | ${tcp.address} 22 | 23 | 24 | ${tcp.port} 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/examples/TCPClientHelper/file.properties: -------------------------------------------------------------------------------- 1 | tcp.address=127.0.0.1 2 | tcp.port=8881 3 | tcp.cto=100 4 | tcp.rto=500 5 | tcp.rlen=1 6 | 7 | -------------------------------------------------------------------------------- /docs/examples/TCPServerHelper/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | resource://includepath://file.properties 7 | 8 | 9 | 10 | 11 | 12 | ${tcp.backlog} 13 | 14 | 15 | ${tcp.rto} 16 | 17 | 18 | ${tcp.rlen} 19 | 20 | 21 | ${tcp.address} 22 | 23 | 24 | ${tcp.port} 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /docs/examples/TCPServerHelper/file.properties: -------------------------------------------------------------------------------- 1 | tcp.address=127.0.0.1 2 | tcp.port= 8881 3 | tcp.backlog=1 4 | tcp.rto=10000 5 | tcp.rlen=1 6 | 7 | -------------------------------------------------------------------------------- /docs/examples/alias-xml/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/examples/alias-yaml/beans.yaml: -------------------------------------------------------------------------------- 1 | beans: !!map 2 | componentA: 3 | class: ComponentA 4 | name: componentB, componentC 5 | 6 | alias: !!map 7 | componentA: componentD, componentE 8 | 9 | -------------------------------------------------------------------------------- /docs/examples/aop-annotation/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /docs/examples/aop-global/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /docs/examples/aop-regex/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/examples/aop/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/examples/arrays/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 1 7 | 2 8 | 3 9 | 4 10 | 11 | 12 | 13 | 14 | 1 15 | 2 16 | 3 17 | 4 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /docs/examples/basic-with-phar/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${user.name} 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/examples/basic/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ${user.name} 5 | 6 | 7 | -------------------------------------------------------------------------------- /docs/examples/bookstore/README: -------------------------------------------------------------------------------- 1 | NOTE: This is a work in progress. The idea is to show you how to create a 2 | complete ding application (in this case, a web application, but all you'll see 3 | can also be applied to a console application). 4 | 5 | Currently, the mvc has some limitations, but the core point is to show how to 6 | use the container to use DI and AOP quite easily. 7 | 8 | This bookstore will use doctrine as its orm, so you should install doctrine2 9 | if you want to run it. 10 | 11 | 12 | # Create the database: 13 | $ cd docs/examples/bookstore 14 | $ doctrine orm:schema:create 15 | 16 | Now setup your apache or lighttpd with a virtual host for docs/examples/bookstore. 17 | You will need a rewrite rule that maps everything not a file to index.php. This 18 | is an example for lighttpd: 19 | 20 | url.rewrite-if-not-file = ( 21 | ".*\?(.*)$" => "/index.php?$1", 22 | "" => "/index.php" 23 | ) 24 | 25 | For apache, you can use something like this: 26 | RewriteRule ^(.*)$ /index.php/$1 -------------------------------------------------------------------------------- /docs/examples/bookstore/cli-config.php: -------------------------------------------------------------------------------- 1 | register(); 6 | 7 | $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__); 8 | $classLoader->register(); 9 | 10 | $container = \Ding\Container\Impl\ContainerImpl::getInstance($properties); 11 | $em = $container->getBean('entityManager'); 12 | 13 | $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( 14 | 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 15 | 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) 16 | )); 17 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/config/application.properties: -------------------------------------------------------------------------------- 1 | application.views = APPLICATION_PUBLIC'/views' 2 | application.language = en_US 3 | 4 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/config/doctrine.properties: -------------------------------------------------------------------------------- 1 | doctrine.db[driver]=pdo_sqlite 2 | doctrine.db[path]=APPLICATION_DATA"/doctrine/bookstore.sqlite" 3 | doctrine.db[dbname]=bookstore 4 | 5 | doctrine.proxy.dir=APPLICATION_DATA"/doctrine/Proxies" 6 | doctrine.proxy.namespace="Proxies" 7 | doctrine.entity.path=APPLICATION_SRC"/BookStore/Domain/Entity" 8 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/config/log4php.properties: -------------------------------------------------------------------------------- 1 | log4php.appender.default = LoggerAppenderDailyFile 2 | log4php.appender.default.layout = LoggerLayoutPattern 3 | log4php.appender.default.layout.ConversionPattern = "%d{ISO8601} [%p] %c: %m%n" 4 | log4php.appender.default.file = /tmp/ding-bookstore.log 5 | log4php.rootLogger = DEBUG, default 6 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/config/php.properties: -------------------------------------------------------------------------------- 1 | php.error_reporting=E_ALL 2 | php.display_errors=1 3 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/context/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | file://${application.config}/doctrine.properties 7 | file://${application.config}/php.properties 8 | file://${application.config}/application.properties 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/context/i18n.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | books 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/context/mvc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | .phtml 9 | ${application.views} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | \Exception 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/context/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ${doctrine.db} 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | ${doctrine.proxy.dir} 27 | 28 | 29 | ${doctrine.proxy.namespace} 30 | 31 | 32 | 33 | 36 | 37 | 38 | ${doctrine.entity.path} 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/i18n/books_default.properties: -------------------------------------------------------------------------------- 1 | required = "Required argument" 2 | already_exists = "Already exists" 3 | cant_be_empty = "Cant be empty" 4 | change_language = "Change language" 5 | create_a_book = "Create a book" 6 | title = "Title" 7 | description = "Description" 8 | isbn = "ISBN" 9 | has_been_created = "Title: {1} 10 | Description: {2} 11 | ISBN: {3} 12 | Has been created. 13 | " 14 | create = "Create" 15 | back = "Back" 16 | list_books = "Browse Books" 17 | -------------------------------------------------------------------------------- /docs/examples/bookstore/private/i18n/books_es_ES.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcelog/Ding/aad50c28e99509f22c9cb1ba54acbeced3b30c50/docs/examples/bookstore/private/i18n/books_es_ES.properties -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Aspect/Profiler.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 17 | } 18 | 19 | /** 20 | * @MethodInterceptor(class-expression=.*AbstractService.*,expression=.*) 21 | */ 22 | public function profileDomainServices(MethodInvocation $invocation) 23 | { 24 | $time = microtime(true); 25 | $originalInvocation = $invocation->getOriginalInvocation(); 26 | $ret = $invocation->proceed(); 27 | $total = microtime(true) - $time; 28 | $this->logger->debug( 29 | "Execution of " 30 | . $originalInvocation->getClass() . "::" . $originalInvocation->getMethod() 31 | . " took: " . sprintf('%.5f', $total) 32 | ); 33 | return $ret; 34 | } 35 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Aspect/Transactional.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 22 | } 23 | 24 | /** 25 | * @MethodInterceptor(class-expression=.*Service.*,expression=.*) 26 | */ 27 | public function manageTransaction(MethodInvocation $methodInvocation) 28 | { 29 | $method = $methodInvocation->getMethod(); 30 | $class = $methodInvocation->getClass(); 31 | if ((strncmp($method, '_', 1) === 0) || (strncmp($method, 'set', 3) === 0)) { 32 | return $methodInvocation->proceed(); 33 | } 34 | $this->logger->debug("Serving for: $class::$method"); 35 | self::$count++; 36 | try 37 | { 38 | if (self::$count === 1) { 39 | $this->logger->debug('Beginning transaction'); 40 | $this->entityManager->beginTransaction(); 41 | } 42 | $result = $methodInvocation->proceed(); 43 | if (self::$count === 1) { 44 | $this->logger->debug('Commiting transaction'); 45 | $this->entityManager->flush(); 46 | $this->entityManager->commit(); 47 | } 48 | self::$count--; 49 | return $result; 50 | } catch(\Exception $exception) { 51 | if (self::$count === 1) { 52 | $this->logger->error('Exception: ' . $exception->getMessage() . ' occurred, rollbacking transaction'); 53 | $this->entityManager->rollback(); 54 | } 55 | self::$count--; 56 | throw $exception; 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Controllers/Exception.php: -------------------------------------------------------------------------------- 1 | add(array('viewName' => 'exception')); 16 | $modelAndView->add(array('exception' => $exception)); 17 | return $modelAndView; 18 | } 19 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Controllers/Main.php: -------------------------------------------------------------------------------- 1 | add(array('viewName' => 'home')); 17 | return $modelAndView; 18 | } 19 | public function __construct() 20 | { 21 | } 22 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Controllers/Settings.php: -------------------------------------------------------------------------------- 1 | setAttribute('LANGUAGE', $language); 21 | $modelAndView = new RedirectModelAndView('/'); 22 | return $modelAndView; 23 | } 24 | public function __construct() 25 | { 26 | } 27 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Domain/Entity/Book.php: -------------------------------------------------------------------------------- 1 | id; 33 | } 34 | 35 | public function getTitle() 36 | { 37 | return $this->title; 38 | } 39 | public function getIsbn() 40 | { 41 | return $this->isbn; 42 | } 43 | 44 | public function getDescription() 45 | { 46 | return $this->description; 47 | } 48 | 49 | public function __construct($title, $isbn, $description) 50 | { 51 | $this->title = $title; 52 | $this->isbn = $isbn; 53 | $this->description = $description; 54 | } 55 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Domain/Repository/BookRepository.php: -------------------------------------------------------------------------------- 1 | entityManager->getRepository("\BookStore\Domain\Entity\\$name"); 18 | } 19 | 20 | /** @Bean */ 21 | public function bookRepository() 22 | { 23 | return $this->getRepository('Book'); 24 | } 25 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/Domain/Service/AbstractService.php: -------------------------------------------------------------------------------- 1 | entityManager->persist($entity); 21 | } 22 | 23 | public function getByIsbn($isbn) 24 | { 25 | return $this->bookRepository->findOneByIsbn($isbn); 26 | } 27 | 28 | public function getAll() 29 | { 30 | return $this->bookRepository->findAll(); 31 | } 32 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/private/src/BookStore/ErrorHandler/ErrorHandler.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 14 | } 15 | 16 | public function onDingError(ErrorInfo $error) 17 | { 18 | $this->logger->error( 19 | "This is your custom error handler: " . print_r($error, true) 20 | ); 21 | } 22 | } -------------------------------------------------------------------------------- /docs/examples/bookstore/public/bootstrap.php: -------------------------------------------------------------------------------- 1 | array( 20 | 'log4php.properties' => APPLICATION_CFG . '/log4php.properties', 21 | 'factory' => array( 22 | 'bdef' => array( 23 | 'xml' => array('filename' => 'beans.xml', 'directories' => array(APPLICATION_BEANS)), 24 | 'annotation' => array('scanDir' => array(APPLICATION_SRC)) 25 | ), 26 | 'properties' => array('application.config' => APPLICATION_CFG) 27 | ), 28 | 'cache' => array() 29 | ) 30 | ); 31 | -------------------------------------------------------------------------------- /docs/examples/bookstore/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcelog/Ding/aad50c28e99509f22c9cb1ba54acbeced3b30c50/docs/examples/bookstore/public/favicon.ico -------------------------------------------------------------------------------- /docs/examples/bookstore/public/index.php: -------------------------------------------------------------------------------- 1 | getModel(); 3 | ?> 4 | 5 | translate('books', $model['errors']['system']) : ''?> 6 | 7 | 8 | translate('books', 'title'); ?>: 9 | 10 | translate('books', $model['errors']['title']) : ''?> 11 | 12 | 13 | translate('books', 'description'); ?>: 14 | 15 | translate('books', $model['errors']['description']) : ''?> 16 | 17 | 18 | translate('books', 'isbn'); ?>: 19 | 20 | translate('books', $model['errors']['isbn']) : ''?> 21 | 22 | 23 | 24 | 25 | 26 | 27 | translate('books', 'back');?> -------------------------------------------------------------------------------- /docs/examples/bookstore/public/views/created.phtml: -------------------------------------------------------------------------------- 1 | getModel(); 3 | ?> 4 | translate('books', 'has_been_created', array( 6 | $model['title'], $model['description'], $model['isbn'] 7 | )); 8 | ?> 9 | translate('books', 'back');?> 10 | -------------------------------------------------------------------------------- /docs/examples/bookstore/public/views/exception.phtml: -------------------------------------------------------------------------------- 1 | getModel(); 3 | var_dump($data['exception']); 4 | 5 | -------------------------------------------------------------------------------- /docs/examples/bookstore/public/views/footer.phtml: -------------------------------------------------------------------------------- 1 |