Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Kernel::getProjectDir()#22315

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:masterfromfabpot:real-root-dir
Apr 7, 2017
Merged

Conversation

@fabpot
Copy link
Member

@fabpotfabpot commentedApr 6, 2017
edited by weaverryan
Loading

QA
Branch?master
Bug fix?yes/no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed ticketsn/a
LicenseMIT
Doc PRsymfony/symfony-docs#7768

Kernel::getRootDir() is misleading. It returns the path whereAppKernel.php is stored, which isapp/ in Symfony 2/3, butsrc/ in Symfony 4. But most of the time, we are usinggetRootDir() to get the project root dir, so%kernel.root_dir%/../ is a common idiom.

Changing the value ofgetRootDir() would be a hard BC break, so I propose to create a new method,getProjectDir() to "replace"getRootDir() gradually.

Taluu, apfelbox, ro0NL, linaori, jvasseur, ScullWM, viviengaetan, grachevko, lunika, sstok, and 8 more reacted with thumbs up emojichalasr, javiereguiluz, linaori, yannickl88, HeahDude, cmen, yceruto, and sensorario reacted with hooray emojilinaori and sensorario reacted with heart emoji
@Taluu
Copy link
Contributor

Taluu commentedApr 6, 2017
edited
Loading

wouldn't it make sense in 4.0 to useroot_dir instead ? didn't see the part on the BC, so nvm

And it's a bit related (but not so much too...), but having the path to the console binary (if there's one) could be useful too

@linaori
Copy link
Contributor

Finally! \o/

viviengaetan, avo7, and jochenmanz reacted with hooray emoji

-----

* Added`kernel.project_dir` and`Kernel::getProjectDir()`
* Deprecated`kernel.root_dir` and`Kernel::getRootDir()`
Copy link
Contributor

Choose a reason for hiding this comment

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

Not happening right?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Virtually at least :) We cannot really display a deprecation as it's used everywhere. But, I want to get rid of it in Symfony Flex, so that in 4, we can really deprecateroot_dir.

Copy link
Contributor

Choose a reason for hiding this comment

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

So it should have a@deprecated but not atrigger_error()?

Copy link
Contributor

Choose a reason for hiding this comment

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

well.. deprecation !== crashing :) then again migrating it is a burden.. so i see we care a bit more here.

Adding@deprecated sounds like a good idea 👍

@nicolas-grekasnicolas-grekas added this to the3.3 milestoneApr 7, 2017
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

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

👍

@fabpotfabpot merged commit1f680cc intosymfony:masterApr 7, 2017
fabpot added a commit that referenced this pull requestApr 7, 2017
This PR was merged into the 3.3-dev branch.Discussion----------Add Kernel::getProjectDir()| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes/no| New feature?  | yes| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | n/a| License       | MIT| Doc PR        | not yet`Kernel::getRootDir()` is misleading. It returns the path where `AppKernel.php` is stored, which is `app/` in Symfony 2/3, but `src/` in Symfony 4. But most of the time, we are using `getRootDir()` to get the project root dir, so `%kernel.root_dir%/../` is a common idiom.Changing the value of `getRootDir()` would be a hard BC break, so I propose to create a new method, `getProjectDir()` to "replace" `getRootDir()` gradually.Commits-------1f680cc added Kernel::getProjectDir()
@fabpotfabpot deleted the real-root-dir branchApril 7, 2017 17:17
@curry684
Copy link
Contributor

curry684 commentedApr 7, 2017
edited
Loading

Why not introduce a getKernelDir method as well? It would allow deprecating getRootDir via phpDoc today, and for real in 4.0. PhpDoc deprecations are only respected by IDEs and code checkers so that should ease transition.

Koc, sstok, and apfelbox reacted with thumbs up emoji

ghost pushed a commit to lazerball/HitTracker that referenced this pull requestApr 7, 2017
This new parameter and method will appear in Symfony 3.3 as persymfony/symfony#22315We will remove it then.
@weaverryan
Copy link
Member

Docs issue created and PR description updated - let's make sure we keep track of everything :) (docs team has a lot of catching up to do, but I hope we'll at least have a complete issue list to work from!)

fabpot added a commit that referenced this pull requestApr 20, 2017
This PR was merged into the 3.3-dev branch.Discussion----------[HttpKernel] sync upgrade files| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#22315| License       | MIT| Doc PR        |Commits-------a90e461 sync upgrade files
@fabpotfabpot mentioned this pull requestMay 1, 2017
* @return string The project root dir
*/
publicfunctiongetProjectDir()
{
Copy link
Contributor

Choose a reason for hiding this comment

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

This implementation is really strange. It basically assigns the variable twice. Once in the method and once in the constructor.

Copy link
Member

Choose a reason for hiding this comment

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

@Tobion the method itself can be overwritten to change the logic (for instance for people wanting to avoid issues with open base dir). But the Kernel still wants to ensure its private property stores the right thing.

And then, the default implementation relies on the property internally to avoid doing the filesystem traversal multiple times

protected$startTime;
protected$loadClassCache;

private$projectDir;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this isprivate and notprotected like$rootDir. I need to override this in my kernel and can't really do at runtime…

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe the extension point is the public method, not the property.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well the issue is that the property is set in__construct and later used bygetKernelParameters. My kernel does not know the path at construct time, so I would need to override multiple methods for no reason…

Copy link
Contributor

Choose a reason for hiding this comment

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

@iltar Following your argument,this line should use$this->getProjectDir() then. The current code is inconsistent and I suggest that we changeprivate $projectDir toprotected $projectDir so it matchesprotected $rootDir.

Copy link
Member

Choose a reason for hiding this comment

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

Making things protected means we then have to ensure backward compatibility on the access to the property. This is a strong commitment. So we never replace private with protected without a strong use case for it. And if you have one, please open a dedicated issue to discuss it instead of doing it on the merged PR (people are generally looking at opened discussion only when catching up)

Copy link
Contributor

@leofeyerleofeyerMay 17, 2017
edited
Loading

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

See#22728 for alternative

fabpot added a commit that referenced this pull requestMay 23, 2017
This PR was merged into the 3.3 branch.Discussion----------use getProjectDir() when possible| Q             | A| ------------- | ---| Branch?       | 3.3| Bug fix?      | no| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets | continues#22315| License       | MIT| Doc PR        |Commits-------a8e298a use getProjectDir() when possible
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofstof left review comments

@chalasrchalasrchalasr left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

+6 more reviewers

@TobionTobionTobion left review comments

@ro0NLro0NLro0NL left review comments

@aschemppaschemppaschempp left review comments

@leofeyerleofeyerleofeyer left review comments

@linaorilinaorilinaori left review comments

@thewilkybarkidthewilkybarkidthewilkybarkid left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.3

Development

Successfully merging this pull request may close these issues.

14 participants

@fabpot@Taluu@linaori@curry684@weaverryan@nicolas-grekas@stof@Tobion@ro0NL@aschempp@leofeyer@thewilkybarkid@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp