|
1 | 1 | # GitHub Release Updater |
| 2 | + |
2 | 3 | The GitHub Release Updater is a PHP class that enables you to update your project from the latest GitHub repository releases. The class is simple to use and highly efficient in keeping your project up-to-date with the latest releases. |
3 | 4 |
|
4 | 5 | ## Preparation |
| 6 | + |
5 | 7 | Before using this class, you need to generate a personal access token on GitHub. Follow these steps: |
6 | 8 |
|
7 | 9 | - Go to https://github.com/settings/tokens/new |
8 | 10 | - Select the repository and enable read-only access for Contents and Metadata. |
9 | 11 | - Click on "Generate token" and copy the token. |
10 | 12 |
|
11 | 13 | ## Installation |
| 14 | + |
12 | 15 | To use this class with Composer, follow these steps: |
13 | 16 | - Open a terminal or command prompt in your project's root directory. |
14 | 17 | - Run the following command to initialize a composer.json file in your project: |
| 18 | + |
15 | 19 | ``` |
16 | 20 | composer init |
17 | 21 | ``` |
| 22 | + |
18 | 23 | - Follow the prompts to fill out the details for your project (e.g. package name, description, author, etc.). |
19 | 24 | - Run the following command to install the koderzi/php-github-updater package: |
| 25 | + |
20 | 26 | ``` |
21 | 27 | composer require koderzi/php-github-updater |
22 | 28 | ``` |
| 29 | + |
23 | 30 | This will download the package and its dependencies and add them to your vendor directory. |
| 31 | + |
24 | 32 | - Include the vendor/autoload.php file in your project's to autoload the class provided by the package: |
| 33 | + |
25 | 34 | ``` |
26 | 35 | require_once "vendor/autoload.php"; |
27 | 36 | ``` |
| 37 | + |
28 | 38 | If you're using a framework or other autoloading mechanism, you may not need to include this file manually. |
| 39 | + |
29 | 40 | To use this class with direct download, follow these steps: |
| 41 | + |
30 | 42 | - Retrieve the Updater.php file from the src directory in the repository. |
31 | 43 | - Put the Updater.php file in your project's directory. |
32 | 44 | - include the file to your project's to load the class. |
33 | 45 |
|
34 | 46 | ## Usage |
| 47 | + |
35 | 48 | To initialize the Updater class and start the update process, follow these steps: |
36 | 49 | - Instantiate the GitUpdate class with the following parameters: |
| 50 | + |
37 | 51 | ``` |
38 | 52 | use KoderZi\PhpGitHubUpdater\Updater; |
39 | 53 |
|
40 | | - new Updater($username, $repository, $token, $version, $admin, $mailer); |
| 54 | + new Updater( |
| 55 | + string $username, |
| 56 | + string $repository, |
| 57 | + string $token, |
| 58 | + string $version, |
| 59 | + string $admin, |
| 60 | + string $mailer, |
| 61 | + array $exclude = ['path' => [], 'filename' => []] |
| 62 | + ); |
41 | 63 | ``` |
| 64 | + |
42 | 65 | >- __$username__: Your GitHub username. |
43 | 66 | >- __$repository__: The name of your GitHub repository. |
44 | 67 | >- __$token__: The personal access token you generated earlier. |
45 | 68 | >- __$version__: The current version number of your project. |
46 | 69 | >- __$admin__: The email address of the admin who will receive an email in case of update failure. |
47 | 70 | >- __$mailer__: The email address that the email will be sent from. |
| 71 | +>- __$exclude__: (Optional) An array of directories or files to exclude from the update. |
| 72 | +``` |
| 73 | +// The $exclude array must have the format: |
| 74 | + $exclude = |
| 75 | + [ |
| 76 | + 'path' => [], |
| 77 | + 'filename' => [] |
| 78 | + ] |
| 79 | +``` |
| 80 | + |
48 | 81 | If a new release is available, the class will update your project automatically. |
49 | 82 |
|
50 | 83 | ## Conclusion |
| 84 | + |
51 | 85 | The GitHub Release Updater is a simple and efficient way to keep your project up-to-date with the latest releases on GitHub. It is easy to use and can save you a lot of time and effort. If you have any questions or issues, please feel free to contact us. |
0 commit comments