-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
0.10.0 breaks backwards compatibility but streamlines and improves ma…
…ny components. See CHANGELOG.md.
- Loading branch information
Robin de Graaf
committed
Apr 17, 2017
1 parent
6dc35f5
commit c196abc
Showing
31 changed files
with
588 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,5 @@ | |
"Parable\\": "src/" | ||
} | ||
}, | ||
"bin": ["src/parable"] | ||
"bin": ["parable"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env php | ||
<?php | ||
ini_set('display_errors', '1'); | ||
|
||
/** @var \Parable\Console\App $app */ | ||
$app = require_once(__DIR__ . '/src/Framework/Bootstrap.php'); | ||
|
||
/** @var \Parable\Filesystem\Path $path */ | ||
$path = \Parable\DI\Container::get(\Parable\Filesystem\Path::class); | ||
$path->setBasedir(BASEDIR); | ||
|
||
$app->setName('Parable'); | ||
|
||
// Always add Help & Init | ||
$app->addCommand(\Parable\DI\Container::get(\Parable\Console\Command\Help::class)); | ||
$app->addCommand(\Parable\DI\Container::get(\Parable\Console\Command\Init::class)); | ||
|
||
// Attempt to load commands set by the user | ||
if (file_exists($path->getDir('app'))) { | ||
/** @var \Parable\Framework\Config $config */ | ||
$config = \Parable\DI\Container::get(\Parable\Framework\Config::class)->load(); | ||
if ($config->get('console.commands')) { | ||
// We don't try/catch because the dev shouldn't add non-existing classes. | ||
foreach ($config->get('console.commands') as $commandClassName) { | ||
$app->addCommand(\Parable\DI\Container::get($commandClassName)); | ||
} | ||
} | ||
} | ||
|
||
$app->setDefaultCommand('help'); | ||
$app->run(); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace Parable\Console\Command; | ||
|
||
class Help extends \Parable\Console\Command | ||
{ | ||
/** @var string */ | ||
protected $name = 'help'; | ||
|
||
/** @var string */ | ||
protected $description = 'Shows all commands available.'; | ||
|
||
/** | ||
* @param \Parable\Console\Output $output | ||
* @param \Parable\Console\Input $input | ||
* @param \Parable\Console\Parameter $parameter | ||
* | ||
* @return $this | ||
*/ | ||
public function run( | ||
\Parable\Console\Output $output, | ||
\Parable\Console\Input $input, | ||
\Parable\Console\Parameter $parameter | ||
) { | ||
$output->writeln("<yellow>{$this->app->getName()} help</yellow>"); | ||
$output->writeln('--------------------------------------------------'); | ||
$output->writeln('Available commands:'); | ||
$output->newline(); | ||
|
||
$longestName = 0; | ||
foreach ($this->app->getCommands() as $command) { | ||
$strlen = strlen($command->getName()); | ||
if ($strlen > $longestName) { | ||
$longestName = $strlen; | ||
} | ||
} | ||
|
||
foreach ($this->app->getCommands() as $command) { | ||
$name = $command->getName(); | ||
$output->write(str_pad(" <green>{$name}</green>", $longestName + 22, ' ', STR_PAD_RIGHT)); | ||
$output->write("{$command->getDescription()}"); | ||
$output->newline(); | ||
} | ||
$output->newline(); | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
<?php | ||
|
||
namespace Parable\Console\Command; | ||
|
||
class Init extends \Parable\Console\Command | ||
{ | ||
/** @var string */ | ||
protected $name = 'init'; | ||
|
||
/** @var string */ | ||
protected $description = 'This command initializes a parable structure.'; | ||
|
||
/** @var \Parable\Filesystem\Path */ | ||
protected $path; | ||
|
||
public function __construct( | ||
\Parable\Filesystem\Path $path | ||
) { | ||
$this->path = $path; | ||
} | ||
|
||
/** | ||
* @param \Parable\Console\Output $output | ||
* @param \Parable\Console\Input $input | ||
* @param \Parable\Console\Parameter $parameter | ||
* | ||
* @return $this | ||
*/ | ||
public function run( | ||
\Parable\Console\Output $output, | ||
\Parable\Console\Input $input, | ||
\Parable\Console\Parameter $parameter | ||
) { | ||
$output->writeln([ | ||
"Parable initialization script", | ||
"-----------------------------------", | ||
"This script will initialize Parable's structure.", | ||
"", | ||
"<red>WARNING</red>", | ||
"This will overwrite existing files without notice!", | ||
"", | ||
]); | ||
|
||
for (;;) { | ||
$output->write("Do you want to continue? [y/N] "); | ||
if ($input->getYesNo(false)) { | ||
break; | ||
} else { | ||
$output->writeln(["", "<red>You chose not to continue.</red>", ""]); | ||
return $this; | ||
} | ||
} | ||
|
||
/** @var \Parable\Filesystem\Path $path */ | ||
$output->newline(); | ||
$output->write('Creating folder structure: '); | ||
|
||
$dirs = [ | ||
'app', | ||
'app/Command', | ||
'app/Config', | ||
'app/Controller', | ||
'app/Init', | ||
'app/Model', | ||
'app/Routing', | ||
'app/View', | ||
'app/View/Home', | ||
'public', | ||
]; | ||
|
||
foreach ($dirs as $dir) { | ||
if (!file_exists($this->path->getDir($dir))) { | ||
mkdir($this->path->getDir($dir)); | ||
} | ||
$output->write('.'); | ||
} | ||
|
||
$output->writeln(" <green>OK</green>"); | ||
|
||
$output->write('Copying files: '); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/.htaccess'), | ||
$this->path->getDir('.htaccess') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/public/.htaccess'), | ||
$this->path->getDir('public/.htaccess') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/public/index.php'), | ||
$this->path->getDir('public/index.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/Command/HelloWorld.php'), | ||
$this->path->getDir('app/Command/HelloWorld.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/Config/App.php'), | ||
$this->path->getDir('app/Config/App.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/Controller/Home.php'), | ||
$this->path->getDir('app/Controller/Home.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/Init/Example.php'), | ||
$this->path->getDir('app/Init/Example.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/Model/User.php'), | ||
$this->path->getDir('app/Model/User.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/Routing/App.php'), | ||
$this->path->getDir('app/Routing/App.php') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/View/Home/index.phtml'), | ||
$this->path->getDir('app/View/Home/index.phtml') | ||
); | ||
$output->write('.'); | ||
copy( | ||
$this->path->getDir('vendor/devvoh/parable/structure/app/View/Home/test.phtml'), | ||
$this->path->getDir('app/View/Home/test.phtml') | ||
); | ||
$output->write('.'); | ||
|
||
$output->writeln(" <green>OK</green>"); | ||
|
||
$output->writeln(["", "<green>Completed!</green>", ""]); | ||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Parable\Events; | ||
namespace Parable\Event; | ||
|
||
class Dock | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
<?php | ||
|
||
namespace Parable\Events; | ||
namespace Parable\Event; | ||
|
||
class Hook | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.