diff --git a/docs/getting-start.md b/docs/getting-start.md new file mode 100644 index 0000000..0a2bf07 --- /dev/null +++ b/docs/getting-start.md @@ -0,0 +1,17 @@ +# Getting start + +To start using the EesyPHP framework on your project, you have to firstly install it using [composer](https://getcomposer.org/) : + +```bash +mkdir my_project +cd my_project +composer init --stability dev +# When asking for dependency, search brenard/eesyphp +composer update +``` + +With the provided `eesyphp` CLI tool, you can quickly init a new project: + +```bash +vendor/bin/eesyphp new_project +``` diff --git a/example/locales/.gitignore b/example/locales/.gitignore new file mode 100644 index 0000000..cfeb792 --- /dev/null +++ b/example/locales/.gitignore @@ -0,0 +1,4 @@ +headers.pot +js-*-messages.pot +php-messages.pot +templates-*-messages.pot diff --git a/skel/.gitignore b/skel/.gitignore new file mode 100644 index 0000000..a09d069 --- /dev/null +++ b/skel/.gitignore @@ -0,0 +1,15 @@ +# Ignore vim temporary/backup files +*~ +.*.swp +# Exclude composer installed libs +/vendor +/composer.lock +# Common UNIX user home directory files +/.bash* +/.vim* +/.composer +/.gitconfig +/.vim* +/.less* +/.ssh +/.phplint-cache diff --git a/skel/bin/manage b/skel/bin/manage new file mode 100644 index 0000000..211a8ed --- /dev/null +++ b/skel/bin/manage @@ -0,0 +1,7 @@ +#!/usr/bin/php + array( + "$root_dir_path/config.local.yml", + ), + 'templates' => array( + 'static_directories' => array( + "$root_dir_path/static" + ), + ), + ), + $root_dir_path +); + +$sentry_span = new SentrySpan('core.init', 'Core initialization'); + +// Put here your own initialization stuff + +require 'views/index.php'; + +$sentry_span->finish(); + +# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab diff --git a/skel/includes/views/index.php b/skel/includes/views/index.php new file mode 100644 index 0000000..2eac086 --- /dev/null +++ b/skel/includes/views/index.php @@ -0,0 +1,5 @@ +finish(); } diff --git a/src/Cli.php b/src/Cli.php index c525036..fa7f955 100644 --- a/src/Cli.php +++ b/src/Cli.php @@ -6,6 +6,24 @@ use Exception; class Cli { + /** + * Initialize + * @return void + */ + public static function init() { + if (php_sapi_name() != 'cli') + return; + self :: add_command( + 'new_project', + array('\\EesyPHP\\Cli', 'cli_new_project'), + I18n :: ___("Create a new project using EesyPHP framework"), + null, + I18n :: ___( + "This command could be used to easily build the structure of a new project using the ". + "EesyPHP framework.") + ); + } + /** * Registered commands * @var array @@ -180,4 +198,50 @@ class Cli { } } + /** + * Command to create new project based on EesyPHP framework + * + * @param array $command_args The command arguments + * @return void + */ + public static function cli_new_project($command_args) { + echo "This CLI tool permit to initialize a new project using the EesyPHP framework.\n"; + readline('[Press enter to continue]'); + echo "\n"; + + $root_path = null; + while (!$root_path) { + $root_path = getcwd(); + $input = readline("Please enter the root directory of your new project [$root_path]: "); + if (empty($input)) + break; + if (!is_dir($input)) + echo "Invalid root directory specified: not found or is not a directory\n"; + else if (!is_writeable($input)) + echo "Invalid root directory specified: not writeable\n"; + else + $root_path = $input; + } + $root_path = rtrim($root_path, "/"); + $skel = __DIR__ . "/../skel"; + + foreach ( + $iterator = new \RecursiveIteratorIterator( + new \RecursiveDirectoryIterator($skel, \RecursiveDirectoryIterator::SKIP_DOTS), + \RecursiveIteratorIterator::SELF_FIRST + ) as $item + ) { + $path = "$root_path/".$iterator->getSubPathname(); + if ($item->isDir()) { + if (!mkdir($path)) + die("Fail to create $path directory\n"); + } + else { + if (!copy($item, $path)) + die("Fail to copy file to $path\n"); + } + } + echo "done. Start coding!\n"; + } + } diff --git a/example/static/css/style.css b/static/css/eesyphp.css similarity index 99% rename from example/static/css/style.css rename to static/css/eesyphp.css index 5fbf2aa..3c5c361 100644 --- a/example/static/css/style.css +++ b/static/css/eesyphp.css @@ -54,7 +54,7 @@ img { max-width: 100%; } th a, th a:hover { color: #000; text-decoration: none; - } +} /* * Forms diff --git a/templates/empty.tpl b/templates/empty.tpl index 30a28e5..f20af27 100644 --- a/templates/empty.tpl +++ b/templates/empty.tpl @@ -20,7 +20,7 @@ - + {foreach $css as $path} {/foreach}