Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit 8b7d485

Browse files
committed
Adding /vendor directory to release
1 parent 330d8af commit 8b7d485

File tree

134 files changed

+6377
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

134 files changed

+6377
-0
lines changed

vendor/autoload.php

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
// autoload.php @generated by Composer
4+
5+
require_once __DIR__ . '/composer/autoload_real.php';
6+
7+
return ComposerAutoloaderInit7f8d5b14aa44a1c29058150bd75443ca::getLoader();

vendor/autoload_packages.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
/**
3+
* This file was automatically generated by automattic/jetpack-autoloader.
4+
*
5+
* @package automattic/jetpack-autoloader
6+
*/
7+
8+
namespace Automattic\Jetpack\Autoloader\jpbf90d28dc341be483ccfcf755adac3ca;
9+
10+
// phpcs:ignore
11+
12+
require_once trailingslashit( dirname( __FILE__ ) ) . 'jetpack-autoloader/autoload_functions.php';
13+
14+
set_up_autoloader();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
A custom autoloader for Composer
2+
=====================================
3+
4+
This is a custom autoloader generator that uses a classmap to always load the latest version of a class.
5+
6+
The problem this autoloader is trying to solve is conflicts that arise when two or more plugins use the same package, but one of the plugins uses an older version of said package.
7+
8+
This is solved by keeping an in memory map of all the different classes that can be loaded, and updating the map with the path to the latest version of the package for the autoloader to find when we instantiate the class.
9+
10+
It diverges from the default Composer autoloader setup in the following ways:
11+
12+
* It creates `jetpack_autoload_classmap.php` and `jetpack_autoload_filemap.php` files in the `vendor/composer` directory.
13+
* This file includes the version numbers from each package that is used.
14+
* The autoloader will only load the latest version of the library no matter what plugin loads the library.
15+
16+
17+
Usage
18+
-----
19+
20+
In your project's `composer.json`, add the following lines:
21+
22+
```json
23+
{
24+
"require-dev": {
25+
"automattic/jetpack-autoloader": "^1"
26+
}
27+
}
28+
```
29+
30+
Your project must use the default composer vendor directory, `vendor`.
31+
32+
After the next update/install, you will have a `vendor/autoload_packages.php` file.
33+
Load the file in your plugin via main plugin file.
34+
35+
In the main plugin you will also need to include the files like this.
36+
```php
37+
require_once . plugin_dir_path( __FILE__ ) . '/vendor/autoload_packages.php';
38+
```
39+
40+
Working with Development Versions of Packages
41+
-----
42+
43+
The autoloader will attempt to use the package with the latest semantic version.
44+
45+
During development, you can force the autoloader to use development package versions by setting the `JETPACK_AUTOLOAD_DEV` constant to true. When `JETPACK_AUTOLOAD_DEV` is true, the autoloader will prefer the following versions over semantic versions:
46+
- `9999999-dev`
47+
- Versions with a `dev-` prefix.
48+
49+
50+
Autoloading Standards
51+
----
52+
53+
All new Jetpack package development should use classmap autoloading, which allows the class and file names to comply with the WordPress Coding Standards.
54+
55+
### Optimized Autoloader
56+
57+
An optimized autoloader is generated when:
58+
* `composer install` or `composer update` is called with `-o` or `--optimize-autoloader`
59+
* `composer dump-autoload` is called with `-o` or `--optimize`
60+
61+
PSR-4 and PSR-0 namespaces are converted to classmaps.
62+
63+
### Unoptimized Autoloader
64+
65+
Supports PSR-4 autoloading. PSR-0 namespaces are converted to classmaps.
66+
67+
68+
Autoloader Limitations
69+
-----
70+
71+
Plugin Updates
72+
73+
When moving a package class file, renaming a package class file, or changing a package class namespace, make sure that the class will not be loaded after a plugin update.
74+
75+
The autoloader builds the in memory classmap as soon as the autoloader is loaded. The package class file paths in the map are not updated after a plugin update. If a plugins's package class files are moved during a plugin update and a moved file is autoloaded after the update, an error will occur.
76+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "automattic/jetpack-autoloader",
3+
"description": "Creates a custom autoloader for a plugin or theme.",
4+
"type": "composer-plugin",
5+
"license": "GPL-2.0-or-later",
6+
"require": {
7+
"composer-plugin-api": "^1.1 || ^2.0"
8+
},
9+
"require-dev": {
10+
"phpunit/phpunit": "^5.7 || ^6.5 || ^7.5"
11+
},
12+
"autoload": {
13+
"classmap": [
14+
"src/AutoloadGenerator.php"
15+
],
16+
"psr-4": {
17+
"Automattic\\Jetpack\\Autoloader\\": "src"
18+
}
19+
},
20+
"extra": {
21+
"class": "Automattic\\Jetpack\\Autoloader\\CustomAutoloaderPlugin"
22+
},
23+
"scripts": {
24+
"phpunit": [
25+
"@composer install",
26+
"./vendor/phpunit/phpunit/phpunit --colors=always"
27+
]
28+
},
29+
"minimum-stability": "dev",
30+
"prefer-stable": true
31+
}

0 commit comments

Comments
 (0)