mirror of
https://github.com/opdavies/gmail-filter-builder.git
synced 2025-11-11 12:58:45 +00:00
PHP library for generating importable Gmail filters in XML
|
|
||
|---|---|---|
| src | ||
| templates | ||
| .editorconfig | ||
| .gitignore | ||
| composer.json | ||
| composer.lock | ||
| README.md | ||
gmail-filter-builder
Description
Inspired by the gmail-britta Ruby library, the Gmail Filter Builder generates XML that can be imported into Gmail’s filter settings.
Usage
- Run
composer require opdavies/gmail-filter-builderto download the library. - Create a new PHP file and require
autoload.php. - Create an array of
GmailFilterobjects, each with it’s required methods. - Pass the filters into an instance of
GmailFilterBuilder.
require __DIR__ . '/vendor/autoload.php';
$filters = [];
// Add filters.
$filters[] = GmailFilter::create();
...
// Display the output.
print GmailFilterBuilder($filters);
To generate the output, run PHP on the file - e.g. php generate.php.
By default, the output is displayed on screen. To generate a file, use the greater than symbol followed by a file name - e.g. php generate.php > filters.xml.
Example
For a working example, see the opdavies/gmail-filters repository.
License
MIT