Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/generate providers #12

Merged
merged 19 commits into from May 31, 2017
Merged

Feature/generate providers #12

merged 19 commits into from May 31, 2017

Conversation

thijsbouwes
Copy link
Contributor

Q A
Status READY
Migrations NO
Ticket

Description 📖

  • Added support for registering providers and facades.
  • Added the barryvdh/laravel-debugbar, here you can see to registering for the providers/facades in action.
  • Refactored the app a bit
  • Added more documentation

Steps to test/reproduce 🚶

  1. Pull the branch
  2. Run php skeletor project:create test123 -> build a Laravel 5.4 project with the barryvdh/laravel-debugbar package
  3. After the install, check config/app.php the package reference should be in here.
  4. Run ./vendor/bin/codecept run all the test should pass.

Todos ✅

  • Tests
  • Documentation

Deployment notes

At the moment the registering of packages only works for Laravel. You get a notification, when try to setup the packages on Lumen.

}

[$alias, $facade] = explode('@', $package->getFacade());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of the array destructuring, Travis is failing.
Can i update the project to PHP 7.1? @kielabokkie @titopixelfusion

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thijsbouwes Is it possible to rewrite this bit so it would also work on 7.0? If we want everyone to use it it might hold people back if they have to upgrade their local PHP version to 7.1 if they haven't already.

Copy link
Owner

@kielabokkie kielabokkie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one @thijsbouwes. Just a comment on your question regarding PHP 7.1

@thijsbouwes
Copy link
Contributor Author

@kielabokkie updated the compatible issue, runs fine on php 7 now 😃

@@ -86,11 +87,11 @@ public function setVersion(string $version)
*/
public function getPath(string $path)
{
if(array_key_exists($path, $this->paths)){
return $this->paths[$path];
if(array_key_exists($path, $this->paths) === false){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd simplify with !array_key_exists(...)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@titopixelfusion I disagree, I find the ! is easily missed when skimming through code. I prefer the === false for readability.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kielabokkie I find it can be tricky, cos if you have the value on the right hand side, that means a silly mistake like $var = false (just one equal) is valid syntax and hard to debug. Either way, we should be consistent, in other place we have if(!class_exists($packageClass)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, the both work @kielabokkie @titopixelfusion what do we implement?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO being consistent is the key, it comes down to a personal preference

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thijsbouwes @titopixelfusion is right, we we do it in other places already so then it's better to stick to that. So I'm happy for it to be changed to !array_key_exists(...)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
public function configure(Package $package, Framework $activeFramework)
{
if ($activeFramework->getName() !== 'Laravel') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of hardcode by name, Framework should have a method like configurable() that returns a boolean. In the Laravel one it would be true, all the others false, this way we would have more flexibility in our code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

*/
public function getNewConfig(string $configFile, Package $package)
{
$state = null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this has to be part of the foreach body or we can have side effects depending on how the lines are ordered

public function getNewConfig(string $configFile, Package $package)
{
$state = null;
$appConfig = file($configFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this test easier to test, I recommend to pass an array to the method. This reminds me the Symfony Yaml component, initially it accepted a filename, that it changed to only accept a string (the contents of the file). If we accept an array, we don't care about the source anymore, easier to test.

{
$facade = $package->getFacade();
if (isset($facade) === false) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc block stays we always return a string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the doc blocks

{
$provider = $package->getProvider();
if (isset($provider) === false) {
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrong return value

@@ -86,11 +87,11 @@ public function setVersion(string $version)
*/
public function getPath(string $path)
{
if(array_key_exists($path, $this->paths)){
return $this->paths[$path];
if(array_key_exists($path, $this->paths) === false){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thijsbouwes @titopixelfusion is right, we we do it in other places already so then it's better to stick to that. So I'm happy for it to be changed to !array_key_exists(...)

@kielabokkie kielabokkie merged commit 5e4ee6c into master May 31, 2017
@kielabokkie kielabokkie deleted the feature/generate-providers branch May 31, 2017 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants