Coder Social home page Coder Social logo

zf2-doctrine-skeleton's Introduction

zf2-doctrine-skeleton

Introduction

This is a Zend Framework 2 skeleton (based on the official skeleton https://github.com/zendframework/ZendSkeletonApplication 2.2.6) with integrated Doctrine, Doctrine Migrations, Doctrine Data Fixtures and PHPUnit. I've created an abstract PHPUnit test case for unit tests that will use Doctrine Data Fixtures. An abstract PHPUnit controller test case class exists to run Doctrine Data Fixtures for testing the API.

Prerequisites

  1. In order to build the application, ant and Java are required. A build script exists under the build/ folder that will get the application off the ground.
  2. A vhost must be set up with the environment set to development. See Virtualhost section below.

Installation

Copy build.properties.dist from the build/ folder to build.properties

cd build/
cp build.properties.dist build.properties

Edit the build.properties file and enter your database config

db.host=localhost
db.port=3306
db.user=root
db.password=password
db.name=test_db
db.test.name=testing_db

Note, the db.test.name should specify a separate database. This is so PHPUnit can apply all of the data fixtures to a separate database, leaving your development database as is. I've opted to use Doctrine Data Fixtures so the exact state of the test database is known for every single unit/integration test. Obviously, unit tests won't care about the state of the database, therefore, you can simply extend \PHPUnit_Framework_TestCase, rather, than, AbstractPHPUnitTestCase.

Run rebuild to get the application up and running and apply the necessary config

ant rebuild

The build process will do a number of things:

  1. Run composer to install all of the necessary dependencies
  2. Create development and testing config for environment specific configuration
  3. Use vendor/bin/doctrine-module orm:schema-tool:drop to drop existing schema for the development database
  4. Use vendor/bin/doctrine-module orm:schema-too:update to create schema for the development database
  5. Use vendor/bin/doctrine-module orm:schema-tool:drop to drop existing schema for the testing database
  6. Use vendor/bin/doctrine-module orm:schema-too:update to create schema for the testing database
  7. Apply all migrations under build/migrations to pre-populate the development database

Virtualhost

<VirtualHost *:80>
    ServerName zf2-doctrine-skeleton.dev
    DocumentRoot /path/to/zf2-doctrine-skeleton/public
    SetEnv APP_ENV "development"
    <Directory /path/to/zf2-doctrine-skeleton/public>
        DirectoryIndex index.php
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

zf2-doctrine-skeleton's People

Contributors

danmayden avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.