Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign up2.7.0. Xpdo:: GetService (). Deciding how to use the namespace PHP for classes while respecting the PSR-4 standard #154
Comments
This comment has been minimized.
This comment has been minimized.
Please make such changes. Then I will have the opportunity to publish my work applications, and bring fresh solutions to MODX, which may appeal to a large circle of people and support your project. |
This comment has been minimized.
This comment has been minimized.
Actual for xPDO 3 |
ALexeyP0708
changed the title
2.7.0. Xpdo:: GetService (). Deciding how to use the namespace for classes while respecting the PSR-4 standard
2.7.0. Xpdo:: GetService (). Deciding how to use the namespace PHP for classes while respecting the PSR-4 standard
Jan 13, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ALexeyP0708 commentedJan 13, 2019
•
edited
I understand, it is foolish to offer without detailed tests.
I will explain my situation first.
I am developing in OS "Windows".
It is known that in 'Windows', when writing paths, slash (/) and backslash (\) have the same meaning.
When writing my classes, I used a namespace.
created object service
And it works well in Windows.
Then I wondered if it was working by chance, and in Linux everything would break.
because Linux does not accept a backslash (\) as a path delimiter.
Checked MODX on Linux hosting.
There really is a problem.
Looking at the xPDO code, a solution was found.
modx 2.7.0
File: www \ core \ xpdo \ xpdo.class.php
Class: xPDO
Method: _loadClass
replace line: 653
$fqcn = str_replace ('.', '/', $fqn). '.class.php';
to
$fqcn = str_replace (['.','\\'], '/', $fqn). '.class.php';
And
replace line 662:
$mapfile = strtr ($fqn, '.', '/'). '.map.inc.php';
to
$mapfile = str_replace (['.', '\\'], '/', $fqn). '.map.inc.php';
Changes checked on linux hosting. Everything is working.
These changes will not affect the code as a whole.
They will only conduct a more valid path validation.
And it will be possible to use the class namespace under the PSR-4 standard.
I agree that it is necessary to take a set of measures to implement the full functionality of the PHP namespace.
But this is sometimes enough to enable app development for MODX 2.7 using the PHP namespace.