Skip to content

Commit

Permalink
adding project files
Browse files Browse the repository at this point in the history
-readme
-phpunit
-github ci
-license
-images
  • Loading branch information
spenserhale committed Feb 6, 2024
1 parent 84ddee2 commit 058162f
Show file tree
Hide file tree
Showing 7 changed files with 144 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .deploy.gitignore
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
31 changes: 31 additions & 0 deletions .github/workflows/ci.yml
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
22 changes: 22 additions & 0 deletions LICENSE.txt
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.
Binary file added images/explainer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions phpunit.xml.dist
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>
67 changes: 67 additions & 0 deletions readme.md
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

0 comments on commit 058162f

Please sign in to comment.