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

Implement requirements checker #6

Closed
samdark opened this issue Mar 24, 2013 · 52 comments
Closed

Implement requirements checker #6

samdark opened this issue Mar 24, 2013 · 52 comments
Assignees
Labels
status:under development Someone is working on a pull request. type:feature
Milestone

Comments

@samdark
Copy link
Member

samdark commented Mar 24, 2013

@alanwillms
Copy link
Contributor

PHP 5.5 is almost being released, so the stable versions will be 5.4 and 5.5.

Why don't you start supporting PHP 5.4+? I think until Yii 2 is ready PHP 5.3 will be deprecated.

@samdark
Copy link
Member Author

samdark commented Mar 24, 2013

We have only one minor thing that doesn't work on 5.3 so far so there's basically no need to require 5.4.

@cebe
Copy link
Member

cebe commented Mar 24, 2013

Why don't you start supporting PHP 5.4+? I think until Yii 2 is ready PHP 5.3 will be deprecated.

I think the word "support" is wrong here, we do support 5.4 but do not require it.

@qiangxue
Copy link
Member

Please focus on discussing how the requirement checker should be implemented instead of which version is required. We will choose the minimal version that suits Yii 2 the best.

@samdark
Copy link
Member Author

samdark commented Mar 25, 2013

I think current 1.1 implementation is OK. As a bonus we can move detection code into a separate class and expose it to CLI.

@klimov-paul
Copy link
Member

I would like to have requirements checker as part of the core, which allows to add extra requirements, specific to the particular application.
When I create an application based on Yii this application may add some extra requirements and I would like to have some "requirement checker" out of the box. Such checker could have some interface and ability to add or update some requirements.

@klimov-paul
Copy link
Member

Also it would be good to have both web and console (at least very simple one) interface for the requirement checker.

@rcoelho
Copy link

rcoelho commented Mar 25, 2013

Agreed with @samdark on separating it and with @klimov-paul on making it extensible for the application's own requirements.
With this, we can use the API exposed by the requirements class in an script (an installer or deployer console script) transparently to the user and warn him only if the requirement check fails.

@qiangxue
Copy link
Member

Sounds good to me including a requirement checker class into the core. Would you please propose some design and usage about it?

@bwoester
Copy link
Contributor

Does anyone know a library or tool to take this a step further? I think of an analyzer that collects all used classes and functions, then looks up their requirements from some sort of database. Output might be grouped into PHP versions/ extensions with a list of source code occurrences and counters. Something that could tell you: "Your app requires PHP 5.3, with the extens x, y and z enabled. But because of those two lines of code, you need PHP 5.4 and another extension".

@klimov-paul
Copy link
Member

There is an important question in this matter: how old PHP version should "requirements checker" support.
By support I mean it should run without errors like "unknown function 'some'".
At the moment I am working on the solution which requires PHP 4.3 as minimum, but still provide an object interface.

@qiangxue
Copy link
Member

Can you insert a line in front of the class to detect the minimal PHP requirement for running the requirement checker?

@klimov-paul
Copy link
Member

Of course,I can use something like:

if (version_compare(get_php_version(), '4.3','<')) {
    echo('PHP 4.3 or higher required');
    exit(1);
}
class RequirementChecker {
    ...
}

@klimov-paul
Copy link
Member

However, the higher minimum supported version, would allow creation of more gracefull implementation.

@qiangxue
Copy link
Member

I think PHP 5.1 should be fine. For lower versions, the only drawback is the less pretty output.

@qiangxue
Copy link
Member

qiangxue commented Apr 4, 2013

mb_string as a required extension: #26

@klimov-paul
Copy link
Member

Implementation created under "yii/requirements".
Script "requirements.php" has been added to "bootstrap" application.

@klimov-paul
Copy link
Member

Created implementation is based on "requirements" solution from Yii 1.1.x.
However, there are several questions, which need to be decided:

  • should the checker suport i18n
  • which requirements should be considered as Yii core ones

@resurtm
Copy link
Contributor

resurtm commented May 11, 2013

@klimov-paul, looks nice but it has problems with 80 characters wide terminals/shells. For instance MinGW Bourne Again Shell window could not be made wider and thus affected by this limitation. Screenshot below:

mingw-bash

@klimov-paul
Copy link
Member

Yes, @resurtm, I see. Need to think about this problem.

@klimov-paul
Copy link
Member

Perhaps the requirement "memo" column should be removed from the console interface.

@resurtm
Copy link
Contributor

resurtm commented May 11, 2013

@klimov-paul, have you thought about expanding each requirements item on two lines? In particular when rendering on terminals narrower than hundred characters.

@mdomba
Copy link
Member

mdomba commented May 11, 2013

the idea of 2 rows is better.. how about having the memo on the second line?

@klimov-paul
Copy link
Member

have you thought about expanding each requirements item on two lines?

I am not sure the list will look good in this way, although may be I should try.

In particular when rendering on shells narrower than hundred characters.

Is there a reliable mechanism to determine terminal width? I suppose no.

@klimov-paul
Copy link
Member

May be I should not try to represent results as table.

@klimov-paul
Copy link
Member

Perhaps it would be better to list the requirements by blocks:

Name: Requirement1
Result: passed
Required by: Yii
Memo: memo1

Name: Requirement2
Result: passed
Required by: Yii
Memo: memo2

Errors: 0 Warnings: 0 Total checks: 2

@samdark
Copy link
Member Author

samdark commented May 11, 2013

Blocks are fine.

@klimov-paul
Copy link
Member

Allright, I will rework console view to use blocks. This seems to be most realiable solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:under development Someone is working on a pull request. type:feature
Projects
None yet
Development

No branches or pull requests

10 participants