Closed l0gicgate closed 4 years ago
I like the thought process of giving the dev an initial core preset with some options. I'm wondering if we can decouple the specific default preset even further.
Before we set up the commands we need to set up the console entry point itself.
We could add a slim-console/bin/init.sh
shell script responsible for publishing the entry point.
composer install slim/slim-console
./vendor/bin/slim-console init
The slim console initialization script would generate a slim
file in the repo root.
#!/usr/bin/env php
<?php
require __DIR__ . '/vendor/autoload.php';
$console = new \Symfony\Component\Console\Application::class;
/**
* Register whatever commands we would need by default here
*
* $console->add(new \Slim\Console\Commands\Make\PublicDirectoryCommand::class);
* $console->add(new \Slim\Console\Commands\Preset\DependencyContainerCommand::class);
* $console->add(new \Slim\Console\Commands\Preset\PSR7ServiceRequestCommand::class);
* $console->add(new \Slim\Console\Commands\Preset\PSR3MonologCommand::class);
*
* Walkthrough each of the defined preset commands and give user options
* $console->add(new \Slim\Console\Commands\Preset\WizardCommand::class);
*/
/**
* Run Command
*/
$console->run();
/**
* Exit Console Application
*/
exit();
php slim preset:wizard
This would allow us to stick to the actual core slim setup with the addition of slim-console and the given console implementation we decide to go with.
We wouldn't need to depend on a single command to set up a structure and eventually we could decouple or override the default application structure defined by the preset commands from slim-console.
The slim console initialization script would generate a slim file in the repo root.
Typically you would have an application land in the vendor/bin
directory. This will be addressed in the first PR and we can all discuss if what I came up with is the right solution.
php slim preset:wizard
This would allow us to stick to the actual core slim setup with the addition of slim-console and > the given console implementation we decide to go with. I really like the idea of having a setup/init command with a preset and an option to do things manually.
- setup:wizard
- setup:preset
Great idea!
@ABGEO07 would you like to work on this command after #4 is merged? I know everyone was very eager to collaborate on this. Let me know
@l0gicgate Sure, I can work on this, but after merging #4 we have to decide what to do with #6.
I also have one question, whether Slim or Slim Skeleton will depend on Slim Console or users will install it globally and run from the global Composer vendor/bin/slim
? In the case of Symfony Skeleton, it has a dependency on the Symfony Console, and we can manage the lifecycle of our project from ./bin/console
. I think it would be great to make Slim Console part of Slim Skeleton.
@ABGEO07 it’s a good idea, I’m curious as to how that would work considering the current skeleton has maybe a few too many things in it at the moment versus what a blank project would look like.
@l0gicgate We can offer users the following method:
php bin/slim init
). After that, the necessary empty project is created interactively.What do you think of this solution?
I think that’s a good solution @ABGEO07
@ABGEO07 Okaay, I think I'm tracking now
Slim Core ~ Console Setup Will Require A Dev To Run
composer require slim/console
./vendor/bin/slim-console init
Slim Skeleton ~ Console Setup Removes The Need To Run Those Steps
@l0gicgate Then i'll wait @flangofas when he will provide PR for #6, and after the merge I will start working on it.
@zhorton34 Slim Skeleton provides everything for a working application and does not need initialization. If the user wants to start from scratch, he/she requires Slim Console and runs the init command to create the structure described here.
@ABGEO07 sounds good!
So what should we call the command to setup a project from scratch?
We need a command that has a default preset and one that’s a setup wizard that walks you through choices.
setup:wizard
for choicessetup
or setup:default
for preset with Slim-Psr7, PHP-DI and default dir structure we choose?@l0gicgate Since this command will initialize, start from scratch a new project, what do you think about this command and option?
slim init
- Initialize the project interactively;
slim init --default
- Initialize the project with default/recommended options;
Also this command will setup composer.json
as you said.
Alright sounds like we got it nailed down @ABGEO07!
@l0gicgate @ABGEO07 Will the "Init" command create the slim-console.config file in the project's root directory as well, right? 😄
@flangofas yes. We need to create the parameters for that config object though. We should define what those parameters are in #6.
@l0gicgate i think i can start working on this.
What did we decide about the global installation? Is this really necessary, or will we only have Slim Console as a project dependency?
@ABGEO I think that we can go with global. This may change if we run into weird complexity though. Also make sure you make the initial PR a draft, don't waste time writing tests as I foresee a lot of changes along the way.
Can you list what the initial command will do just so we're on the same page before we begin?
@l0gicgate as we agreed earlier, we will have two types of initialization: 1) with default settings and 2) with interactive setup.
As you described in this issue, in the interactive initialization wizard, the user will configure:
composer init
command and it will setup composer.json)Sounds good to me @ABGEO! Just for future notes I think we should probably include minimum 2 different skeleton types. Right now Slim-Skeleton
is for an API while a lot of people still seem to need one for static websites and use it with Twig
. Should we also include that initially?
Should we also include that initially?
@l0gicgate i think yes. The first thing that comes to mind is initialization profiles, something like
slim init --profile (web-skeleton || api-skeleton || something-else)
. What do you think?
yeah I think that's a good idea @ABGEO. @adriansuter thoughts on the naming?
Not sure if the term skeleton
is needed, if we talk about profiles. So api
and web
would be enough.
I agree @adriansuter. Let's go with that naming convention api|web
@ABGEO
Okay guys I will start working on this.
@l0gicgate I have a question, we can create some default files (app/dependencies.php
, app/middleware.php
, app/settings.php
, public/index.php
...) and create a working application if the user selects the default dependencies (Slim PSR-7, PHP DI, Monolog), but what to do with other options? In the case of the dependency container, we should also get user input as you described.
I think a good way to approach this, and allow custom user commands is to use the Slim-Skeleton template, but with the commands addition:
app
|--commands.php
|--dependencies.php
|--middleware.php
|--routes.php
|--settings.php
logs
|--*empty*
public
|--index.php
src
|--*empty*
tests
|--bootstrap.php
.gitignore
composer.json
phpunit.xml
This way we have a specific place to look for commands alongside the default ones provided with the cli itself.
@ABGEO sorry I've been unavailable, I am super busy with doing contractual work at the moment. I will try to respond when I can. I can't provide a timeline at the moment. @adriansuter may be able to help review and comment though if he has time.
@l0gicgate Np. I have more time for thinking and refactoring 😃
As per my comment in the original thread, I would like to have discussions about the functionality and structure of each command. In this case, this comment would do the following:
slim/psr7
but choices would be (Laminas, Guzzle or Nyholm)php-di/php-di
but choices would be (Pimple or overridden by user input)As for initial directory structure we should stick to something like
Slim-Skeleton
:Please provide some input y'all!