Skip to content

Instantly share code, notes, and snippets.

@hujuice
Last active January 7, 2018 11:49
Show Gist options
  • Save hujuice/077819c20ac08c1537d866c43c6fc0ae to your computer and use it in GitHub Desktop.
Save hujuice/077819c20ac08c1537d866c43c6fc0ae to your computer and use it in GitHub Desktop.
Blessed repository Git hooks for a PHP project
#!/usr/bin/env bash
# -------------------------------------------------------------#
# Generate the documentation from /docs/ #
# Generate LOC #
# -------------------------------------------------------------#
# Sergio Vaccaro <sergio,vaccaro@istat.it>
# Note: add the following to your project
# composer require --dev "yiisoft/yii2-apidoc": "dev-master#96e1651"
# composer require --dev "phploc/phploc": "4.0.1"
# Generate docs
# =============
echo "Generating documentation and API references"
echo "-------------------------------------------"
# Note: this script is an overkill because it is a workaround to
# this bug: https://github.com/yiisoft/yii2-apidoc/issues/131
PROJECT_PATH=/var/www/vhosts/istat/contactcentre
DOCS_PATH="${PROJECT_PATH}/local/docs"
cd $PROJECT_PATH
# Free the wrong cache and index
rm -fr local/docs/cache
rm -f local/docs/index.html
# Generate the api docs without yii and save the index.html
php -d memory_limit=256M vendor/bin/apidoc api . $DOCS_PATH --exclude="docs,environments,local,vendor" --guide=. --pageTitle="Contact Centre Class Reference" --interactive=0
mv local/docs/index.html local/docs/api-index.html
# Generate the api docs with yii and save the index.html
php -d memory_limit=256M vendor/bin/apidoc api vendor/yiisoft/yii2,vendor/yiisoft/yii2-debug,vendor/yiisoft/yii2-authclient,. $DOCS_PATH --exclude="docs,environments,local,vendor" --guide=. --pageTitle="Contact Centre Class Reference" --interactive=0
mv local/docs/index.html local/docs/yii-index.html
# Symlink the wanted index.html
ln -s api-index.html local/docs/index.html
# Generate the guide
php -d memory_limit=256M vendor/bin/apidoc guide docs $DOCS_PATH --apiDocs=. --pageTitle="Contact Centre Software Guide" --interactive=0
echo "Documentation available at /docs/"
echo
# Generate LOC
# ============
echo "Generating LOCs"
echo "---------------"
# LOC file
LOCFILE="local/docs/loc.txt"
vendor/bin/phploc --exclude=vendor --exclude=local . > "$LOCFILE"
echo "LOC analysis report at ${LOCFILE}"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment