-
Notifications
You must be signed in to change notification settings - Fork 846
Add instructions on package installation and usage #12576
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
09fa4a1
Add instructions on package installation and usage
eliorivero c91ab19
Move content about installing Composer to the doc regarding developme…
eliorivero 1d2153c
Explain how to install Composer on systems other than macOS. Props @a…
eliorivero f9547b3
Update docs/development-environment.md
eliorivero 1f38edb
Apply suggestions from code review
eliorivero b0f2212
Add reference to Composer installation in the section that explains h…
eliorivero e63601d
Merge remote-tracking branch 'origin/add/packages-readme' into add/pa…
eliorivero File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| # Jetpack packages for Development | ||
|
|
||
| These Composer packages offer a unified codebase that we will share among projects under the Jetpack brand. | ||
|
|
||
| ## Installing Composer | ||
eliorivero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| You need Composer to use the packages. If you don't have it installed, go and check how to [install Composer](https://github.com/Automattic/jetpack/blob/master/docs/development-environment.md#installing-composer) and then continue here. | ||
|
|
||
eliorivero marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ## Defining required packages | ||
|
|
||
| You need to create a `composer.json` file in your project root. For example, this is the file in VaultPress that requires the Jetpack logo package. | ||
|
|
||
| ```json | ||
| { | ||
| "name": "automattic/vaultpress", | ||
| "description": "VaultPress is a subscription service offering real-time backup, automated security scanning, and support from WordPress experts.", | ||
| "homepage": "https://vaultpress.com/", | ||
| "type": "wordpress-plugin", | ||
| "license": "GPL-2.0-or-later", | ||
| "support": { | ||
| "issues": "https://github.com/Automattic/vaultpress/issues" | ||
| }, | ||
| "require": { | ||
| "automattic/jetpack-logo": "1.0.0" | ||
| }, | ||
| "require-dev": { | ||
| "automattic/jetpack-standards": "master-dev" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Installing packages | ||
|
|
||
| Once you have defined your package requirements, run | ||
|
|
||
| ``` | ||
| composer install | ||
| ``` | ||
|
|
||
| and that will install the required Composer packages. | ||
|
|
||
| ### Using packages | ||
|
|
||
| To use something from a package, you have to declare it at the top of the file before any other instruction, and then use it in the code. For example, the logo can be used like this: | ||
|
|
||
| ```php | ||
| use Automattic\Jetpack\Assets\Logo; | ||
|
|
||
| // other code... | ||
|
|
||
| $logo = new Logo(); | ||
| ``` | ||
|
|
||
| If you need to rule out conflicts, you can alias it: | ||
|
|
||
| ```php | ||
| use Automattic\Jetpack\Assets\Jetpack_Logo; | ||
|
|
||
| // other code... | ||
|
|
||
| $logo = new Jetpack_Logo(); | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.