-
Notifications
You must be signed in to change notification settings - Fork 255
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
POC: manage third party libs via composer #8240
base: release-3.0
Are you sure you want to change the base?
Conversation
Sources/Actions/Admin/ACP.php
Outdated
@@ -1523,8 +1523,7 @@ public static function getFileVersions(array &$versionOptions): array | |||
); | |||
|
|||
$ignore_sources = [ | |||
Config::$sourcedir . '/minify/*', | |||
Config::$sourcedir . '/ReCaptcha/*', | |||
Config::$vendordir . '/*', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading the code right, this line can go because ``$vendordiris outside of
$sourcedir`, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right, lines above specify the target which is Sources
Sources/Tasks/ExportProfileData.php
Outdated
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'Exception.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'Exception.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'Exceptions', 'BasicException.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'Exceptions', 'BasicException.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'Exceptions', 'FileImportException.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'Exceptions', 'FileImportException.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'Exceptions', 'IOException.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'Exceptions', 'IOException.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'Minify.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'Minify.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'path-converter', 'src', 'Converter.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'path-converter', 'src', 'Converter.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'CSS.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'CSS.php']); | ||
|
||
include_once implode(DIRECTORY_SEPARATOR, [Config::$sourcedir, 'minify', 'src', 'JS.php']); | ||
include_once implode(DIRECTORY_SEPARATOR, [Config::$vendordir, 'minify', 'src', 'JS.php']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it not be better to just include the Composer autoload file here?
other/update_unicode_data.php
Outdated
@@ -54,7 +54,7 @@ | |||
} | |||
|
|||
// 4. Get some more stuff we need. | |||
require_once $sourcedir . '/Autoloader.php'; | |||
require_once '/vendor/autoload.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the leading slash? Wouldn't that try to look in the top directory?
index.php
Outdated
$loader = require SMF\Config::$vendordir . '/autoload.php'; | ||
$third_party_mappers = []; | ||
|
||
// Ensure $sourcedir is set to something valid. | ||
if (class_exists(Config::class, false) && isset(Config::$sourcedir)) { | ||
$sourcedir = Config::$sourcedir; | ||
} | ||
|
||
require_once SMF\Config::$sourcedir . '/Autoloader.php'; | ||
if (empty($sourcedir) || !is_dir($sourcedir)) { | ||
$sourcedir = __DIR__; | ||
} | ||
|
||
// Do any third-party scripts want in on the fun? | ||
if (!defined('SMF_INSTALLING') && class_exists(Config::class, false)) { | ||
if (!class_exists(IntegrationHook::class, false) && is_file($sourcedir . '/IntegrationHook.php')) { | ||
require_once $sourcedir . '/IntegrationHook.php'; | ||
} | ||
|
||
if (class_exists(IntegrationHook::class, false)) { | ||
IntegrationHook::call('integrate_autoload', [&$third_party_mappers]); | ||
} | ||
} | ||
|
||
foreach ($third_party_mappers as $prefix => $dirname) { | ||
$loader->addPsr4($prefix, $dirname); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to see this code moved back into an autoloader class file rather than having it here in index.php.
Part of the reason for moving the existing autoloading code into a separate class was to avoid polluting the global namespace with variables in index.php. (Note: when backward compatibility support is enabled we end up putting references to class variables from SMF's namespace into the global namespace anyway, but the idea is to eliminate that in a future version.)
remove more calls to code in sources folder
Co-authored-by: John Rayes <[email protected]>
Co-authored-by: John Rayes <[email protected]>
21e27b0
to
f608581
Compare
This is a simple POC for allowing SMF to handle their internal third party libraries via composer.
Some key features to take into consideration for this POC