-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
-readme -phpunit -github ci -license -images
- Loading branch information
1 parent
84ddee2
commit 058162f
Showing
7 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,10 @@ | ||
/.github/ | ||
/.idea/ | ||
/build/ | ||
/tests/ | ||
.gitignore | ||
phpunit.xml | ||
phpunit.xml.dist | ||
DOCKER_ENV | ||
docker_tag | ||
output.log |
This file contains 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,31 @@ | ||
name: CI | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Prepare for production | ||
run: | | ||
rm .gitignore | ||
mv .deploy.gitignore .gitignore | ||
rm -rf .github | ||
rm -rf .idea | ||
rm -rf .vscode | ||
rm -rf build | ||
rm -rf tests | ||
rm phpunit.xml.dist | ||
- name: Create a built branch | ||
run: | | ||
BRANCH_NAME=$(echo $GITHUB_REF | grep -oP '(?<=refs\/heads\/).*') | ||
git config --global user.email "actions@github.com" | ||
git config --global user.name "GitHub Action CI" | ||
git remote set-url origin https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git | ||
git checkout -b $BRANCH_NAME-built | ||
git add -A && git commit -m "built from $GITHUB_SHA" | ||
git push --force -u origin $BRANCH_NAME-built |
This file contains 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,22 @@ | ||
WordPress AutoHook Library | ||
Copyright (C) 2024 Spenser Hale | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
Additional Permission Under GNU GPL version 3 section 7: | ||
|
||
The name/brand "Spenser Hale" and their associated | ||
branding elements are protected by copyright/trademark law and may not | ||
be used in association with derivative works that are not owned by | ||
Spenser Hale without express written permission. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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,14 @@ | ||
<?xml version="1.0"?> | ||
<phpunit | ||
backupGlobals="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
> | ||
<testsuites> | ||
<testsuite name="unit"> | ||
<directory suffix="Test.php">./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains 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,67 @@ | ||
## WP AutoHooks | ||
|
||
![Screen Shot][product-screenshot] | ||
|
||
WP AutoHooks is a PHP Library that allows you to define Attributes on Classes and Methods to | ||
document and register WordPress Hooks. | ||
|
||
## Features | ||
|
||
- **Developer Experience**: Document hooks next to the method, giving you context and a better developer experience. | ||
- **Performance**: Hooks are registered without loading classes or instantiating objects until needed. | ||
- **Flexibility**: The underlying PHP Library can be used for both simple and complex projects. | ||
- **Modularity**: Ability to add and remove standalone classes quickly and easily. | ||
|
||
<!-- GETTING STARTED --> | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
By default, the library is geared toward Composer, but there is flexibility, and you can | ||
integrate the library with your class loading system. | ||
|
||
### Installation | ||
|
||
```sh | ||
composer require spenserhale/wp-autohook-library | ||
``` | ||
|
||
### Basic Usage | ||
|
||
Attribute your class and methods with the `Hook` and `Shortcode` attributes. | ||
```php | ||
#[Hook('cli_init')] | ||
public static function register(): void {...} | ||
``` | ||
#### Build/Wire Up | ||
|
||
```php | ||
// Get the list of classes | ||
$classes = \SH\AutoHook\ComposerJsonParser::getClasses($composerJsonPath); | ||
|
||
// Process classes to string | ||
[$output] = \SH\AutoHook\AttributeResolver::processClassesToString($classes); | ||
|
||
// Write to file | ||
(bool) $written = \SH\AutoHook\FileWriter::write($output, $outputPath); | ||
``` | ||
|
||
## Tests | ||
|
||
To run tests, make sure to create class list through composer: | ||
```sh | ||
composer du -o | ||
``` | ||
|
||
Then run the tests: | ||
```sh | ||
composer test | ||
``` | ||
|
||
<p align="right">(<a href="#readme-top">back to top</a>)</p> | ||
|
||
<!-- MARKDOWN LINKS & IMAGES --> | ||
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --> | ||
|
||
[product-screenshot]: images/explainer.png |