Skip to content

Instantly share code, notes, and snippets.

@joekarasek
Created February 11, 2016 21:20
Show Gist options
  • Save joekarasek/98d830efc3a1e937bc0c to your computer and use it in GitHub Desktop.
Save joekarasek/98d830efc3a1e937bc0c to your computer and use it in GitHub Desktop.
commands to set up a new php/silex project
#!/bin/sh
echo "project name:"
read PROJECT_NAME
echo "port to use:"
read PORT
mkdir ~/${PROJECT_NAME}
cd ~/${PROJECT_NAME}
mkdir app web src views
echo vendor/ > .gitignore
echo "<?php \n\t\$website = require_once __DIR__.'/../app/app.php'; \n\t\$website->run(); ?>" > web/index.php
echo "<?php \n\n\trequire_once __DIR__.'/../vendor/autoload.php'; \n\n\t\$app = new Silex\Application(); \n\n\t\$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__.'/../views')); \n\n\t\$app->get('/', function(){return 'Hello, World!';}); \n\n\treturn \$app; \n\n?>" > app/app.php
composer require --prefer-source --no-interaction silex/silex:~1.1 twig/twig:~1.0
atom ~/${PROJECT_NAME}
cd web
php -S localhost:${PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment