Skip to content

Instantly share code, notes, and snippets.

@joseluisq
Created October 20, 2014 15:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joseluisq/43c9d8032cbd2fe688d3 to your computer and use it in GitHub Desktop.
Save joseluisq/43c9d8032cbd2fe688d3 to your computer and use it in GitHub Desktop.
Linux shell script to generate entities for PHP Doctrine 2
#!/bin/sh
# Doctrine 2 Entities Generator v0.1
# ==================================
# Requirements
# ============
# It's necessary to create a composer project before exec this script.
# More info about composer at https://getcomposer.org/doc/00-intro.md
echo Doctrine 2 Entities Generator v0.1
echo ==================================
# Remove ./config/yaml directory before
rm -rf ./config/yaml
# Create yaml directory
mkdir ./config/yaml
# Read the ./cli-config.php (by default) and generate mapping yaml files to ./config/yaml directory
php vendor/bin/doctrine orm:convert-mapping --namespace="" --force --from-database yml ./config/yaml
# Generated models to ./src directory
php vendor/bin/doctrine orm:generate-entities --generate-annotations=false --update-entities=true --generate-methods=false ./src
# Validate schema
php vendor/bin/doctrine orm:validate-schema
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment