Skip to content

hmg-suman/zf2-doctrine2-getting-started

 
 

Repository files navigation

ZF2 Skeleton & Doctrine2 Getting Started

Introduction

This is a fork of the ZF2 Skeleton application. It combines this project with the getting started tutorial of doctrine2, available under http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/tutorials/getting-started-xml-edition.html .

Installation

Using Composer

The recommended way to get a working copy of this project is to clone the repository and use composer to install dependencies:

cd my/project/dir
git clone git://github.com/iwalz/zf2-doctrine2-getting-started.git
cd zf2-doctrine2-getting-started
php composer.phar install

Creating database scheme

If you've installed doctrine from within this composer file, you've to change "vendor/bin/doctrine.php" on line on line 28:

   $configFile = getcwd() . DIRECTORY_SEPARATOR . 
   		'config'. DIRECTORY_SEPARATOR .
   		'doctrine'. DIRECTORY_SEPARATOR .'cli-config.php';

Note: If you run php bin/prepareconfig.php

This will be done automatically.

After that you can create the database scheme:

php vendor/bin/doctrine orm:schema-tool:create

Maybe vou've to change the connectionsettings in bootstrap_config.php and bootstrap_doctrine.php:

// database configuration parameters
$conn = array(
    'driver'   => 'pdo_mysql',
    'host'     => '127.0.0.1',
    'dbname'   => 'zfdoctrine2',
    'user'     => 'test',
    'password' => 'test'
);

Generating Proxy files

To re-generate the proxy files based on the module configuration, you've to run:

php vendor/bin/doctrine orm:generate-proxies data/DoctrineORMModule/Proxy

Configuring the doctrine module

Note: If you run php bin/prepareconfig.php

This will be done automatically.

For the current project, the module.config.php from "vendor/doctrine/doctrine-orm-module/config/module.config.php" has to look like this:

<?php
return array(
    'doctrine' => array(
        'orm_autoload_annotations' => true,

        'connection' => array(
            'orm_default' => array(
                'configuration' => 'orm_default',
                'eventmanager'  => 'orm_default',

                'params' => array(
                    'host'     => 'localhost',
                    'port'     => '3306',
                    'user'     => 'test',
                    'password' => 'test',
                    'dbname'   => 'zfdoctrine2',
                )
            ),
        ),

        'configuration' => array(
            'orm_default' => array(
                'metadata_cache'    => 'array',
                'query_cache'       => 'array',
                'result_cache'      => 'array',

                'driver'            => 'orm_default',

                'generate_proxies'  => false,
                'proxy_dir'         => realpath(__DIR__.'/../../../../data/DoctrineORMModule/Proxy'),
                'proxy_namespace'   => 'DoctrineProxies'
            )
        ),

        'driver' => array(
            'orm_default' => array(
                'class'   => 'Doctrine\ORM\Mapping\Driver\XmlDriver',
                'paths' => array(__DIR__.'/../../../../config/doctrine/xml')
            )
        ),

        'entitymanager' => array(
            'orm_default' => array(
                'connection'    => 'orm_default',
                'configuration' => 'orm_default'
            )
        ),

        'eventmanager' => array(
            'orm_default' => array()
        ),

        'sql_logger_collector' => array(
            'orm_default' => array(),
        ),

        'entity_resolver' => array(
            'orm_default' => array()
        )
    ),

    // zendframework/zend-developer-tools specific settings

    'view_manager' => array(
        'template_map' => array(
            'zend-developer-tools/toolbar/doctrine-orm' => __DIR__ . '/../view/zend-developer-tools/toolbar/doctrine-orm.phtml',
        ),
    ),

    'zenddevelopertools' => array(
        'profiler' => array(
            'collectors' => array(
                'orm_default' => 'doctrine.sql_logger_collector.orm_default',
            ),
        ),
        'toolbar' => array(
            'entries' => array(
                'orm_default' => 'zend-developer-tools/toolbar/doctrine-orm',
            ),
        ),
    ),
);

Initialize ZendDeveloperTools Toolbar

Note: If you run php bin/prepareconfig.php

This will be done automatically.

Copy "vendor/zendframework/zend-developer-tools/config/zenddevelopertools.local.php.dist" to "config/autoload/zenddevelopertools.local.php" directory

Virtual Host

Afterwards, set up a virtual host to point to the public/ directory of the project and you should be ready to go!

<VirtualHost *:80>
	ServerName zf2-doctrine2.local
	DocumentRoot "/var/www/zf2-doctrine2/public/"
	
	<Directory "/var/www/zf2-doctrine2/public">
		AllowOverride All
		Order allow,deny
		allow from all
	</Directory>

</VirtualHost>

About

This project combines the ZF2 SkeletonApplication and the doctrine2 getting started project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 66.2%
  • HTML 31.6%
  • CSS 1.9%
  • ApacheConf 0.3%