|
| 1 | +# php-aegis Positioning & Target Audience |
| 2 | + |
| 3 | +## The Problem We Discovered |
| 4 | + |
| 5 | +After integrating php-aegis with multiple WordPress projects (themes and plugins), we found: |
| 6 | + |
| 7 | +> **WordPress already has comprehensive security APIs** (`esc_html()`, `esc_attr()`, `wp_kses()`, etc.) that are deeply integrated with the WordPress ecosystem. |
| 8 | +
|
| 9 | +This means php-aegis **should not compete** with WordPress core functions. Instead, it should: |
| 10 | + |
| 11 | +1. **Target non-WordPress PHP applications** where no security API exists |
| 12 | +2. **Provide unique capabilities** that WordPress (and other frameworks) lack |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Target Audience Matrix |
| 17 | + |
| 18 | +| Audience | php-aegis Value | Recommendation | |
| 19 | +|----------|-----------------|----------------| |
| 20 | +| **WordPress plugins/themes** | Low | Use WordPress core functions | |
| 21 | +| **Laravel applications** | Medium | Use Laravel's helpers, aegis for gaps | |
| 22 | +| **Symfony applications** | Medium | Use Twig's escaping, aegis for gaps | |
| 23 | +| **Vanilla PHP applications** | **High** | php-aegis is the primary security layer | |
| 24 | +| **API-only services** | **High** | No view layer = no framework escaping | |
| 25 | +| **CLI tools** | **High** | No framework = aegis fills the gap | |
| 26 | +| **Microservices** | **High** | Lightweight, zero-dependency | |
| 27 | +| **Semantic Web apps** | **Very High** | TurtleEscaper is unique | |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## What WordPress Has (Don't Duplicate) |
| 32 | + |
| 33 | +| WordPress Function | Purpose | php-aegis Equivalent | |
| 34 | +|--------------------|---------|---------------------| |
| 35 | +| `esc_html()` | HTML content escaping | `Sanitizer::html()` | |
| 36 | +| `esc_attr()` | HTML attribute escaping | `Sanitizer::attr()` | |
| 37 | +| `esc_url()` | URL escaping with protocol check | `Sanitizer::url()` | |
| 38 | +| `esc_js()` | JavaScript escaping | `Sanitizer::js()` | |
| 39 | +| `wp_kses()` | HTML filtering with allowlist | ❌ Not implemented | |
| 40 | +| `wp_kses_post()` | HTML filtering for posts | ❌ Not implemented | |
| 41 | +| `sanitize_text_field()` | Text sanitization | `Sanitizer::stripTags()` | |
| 42 | +| `is_email()` | Email validation | `Validator::email()` | |
| 43 | +| `wp_http_validate_url()` | URL validation + SSL | `Validator::url()` | |
| 44 | +| `absint()` | Positive integer | `Validator::int(..., min: 0)` | |
| 45 | + |
| 46 | +**For WordPress projects**: Use WordPress functions. They're more battle-tested, ecosystem-integrated, and maintained by Automattic. |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## What php-aegis Provides (Unique Value) |
| 51 | + |
| 52 | +These capabilities are **not available** in WordPress, Laravel, or Symfony: |
| 53 | + |
| 54 | +### 1. RDF/Turtle Escaping (Unique) |
| 55 | + |
| 56 | +No other PHP library provides W3C-compliant Turtle escaping. |
| 57 | + |
| 58 | +```php |
| 59 | +use PhpAegis\TurtleEscaper; |
| 60 | + |
| 61 | +// Safe for semantic web applications |
| 62 | +TurtleEscaper::string($userLabel); |
| 63 | +TurtleEscaper::iri($userProvidedUri); |
| 64 | +TurtleEscaper::triple($subject, $predicate, $object, 'en'); |
| 65 | +``` |
| 66 | + |
| 67 | +**Use cases**: |
| 68 | +- Linked Data platforms |
| 69 | +- Knowledge graphs |
| 70 | +- Semantic WordPress themes (like wp-sinople-theme) |
| 71 | +- SPARQL endpoint integrations |
| 72 | + |
| 73 | +### 2. Security Headers Helper |
| 74 | + |
| 75 | +WordPress doesn't provide header helpers. Frameworks have partial support. |
| 76 | + |
| 77 | +```php |
| 78 | +use PhpAegis\Headers; |
| 79 | + |
| 80 | +// One-line security hardening |
| 81 | +Headers::secure(); |
| 82 | + |
| 83 | +// Or fine-grained control |
| 84 | +Headers::contentSecurityPolicy([...]); |
| 85 | +Headers::strictTransportSecurity(maxAge: 31536000, preload: true); |
| 86 | +Headers::permissionsPolicy([...]); |
| 87 | +``` |
| 88 | + |
| 89 | +### 3. Extended Validators Not in WordPress |
| 90 | + |
| 91 | +| php-aegis | WordPress Equivalent | Notes | |
| 92 | +|-----------|---------------------|-------| |
| 93 | +| `Validator::uuid()` | ❌ None | RFC 4122 UUID validation | |
| 94 | +| `Validator::ip()` | ❌ None | IPv4/IPv6 validation | |
| 95 | +| `Validator::ipv4()` | ❌ None | IPv4 only | |
| 96 | +| `Validator::ipv6()` | ❌ None | IPv6 only | |
| 97 | +| `Validator::domain()` | ❌ None | RFC 1035 domain validation | |
| 98 | +| `Validator::hostname()` | ❌ None | Domain or IP | |
| 99 | +| `Validator::slug()` | `sanitize_title()` | WP sanitizes, aegis validates | |
| 100 | +| `Validator::semver()` | ❌ None | Semantic versioning | |
| 101 | +| `Validator::iso8601()` | ❌ None | ISO 8601 datetime | |
| 102 | +| `Validator::hexColor()` | `sanitize_hex_color()` | WP sanitizes, aegis validates | |
| 103 | +| `Validator::safeFilename()` | `sanitize_file_name()` | WP sanitizes, aegis validates | |
| 104 | +| `Validator::json()` | ❌ None | JSON structure validation | |
| 105 | +| `Validator::int(min, max)` | ❌ None | Integer with range | |
| 106 | +| `Validator::printable()` | ❌ None | ASCII printable only | |
| 107 | +| `Validator::noNullBytes()` | ❌ None | Path traversal prevention | |
| 108 | +| `Validator::httpsUrl()` | `wp_http_validate_url()` | WP has `$ssl` param | |
| 109 | + |
| 110 | +### 4. Zero Dependencies |
| 111 | + |
| 112 | +- WordPress functions require WordPress |
| 113 | +- Laravel helpers require Laravel |
| 114 | +- Symfony components require Symfony |
| 115 | + |
| 116 | +php-aegis works in any PHP 8.1+ environment with no dependencies. |
| 117 | + |
| 118 | +--- |
| 119 | + |
| 120 | +## Recommended Usage Patterns |
| 121 | + |
| 122 | +### For WordPress Projects |
| 123 | + |
| 124 | +```php |
| 125 | +// DON'T: Use php-aegis for basic escaping |
| 126 | +echo \PhpAegis\Sanitizer::html($content); // ❌ Redundant |
| 127 | + |
| 128 | +// DO: Use WordPress functions |
| 129 | +echo esc_html($content); // ✅ Preferred |
| 130 | + |
| 131 | +// DO: Use php-aegis for unique capabilities |
| 132 | +$headers = new \PhpAegis\Headers(); |
| 133 | +$headers::secure(); // ✅ WordPress lacks this |
| 134 | + |
| 135 | +// DO: Use php-aegis for semantic web features |
| 136 | +echo \PhpAegis\TurtleEscaper::string($label); // ✅ WordPress lacks this |
| 137 | + |
| 138 | +// DO: Use php-aegis for validation gaps |
| 139 | +if (!\PhpAegis\Validator::uuid($_GET['id'])) { // ✅ WordPress lacks this |
| 140 | + wp_die('Invalid ID'); |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +### For Laravel Projects |
| 145 | + |
| 146 | +```php |
| 147 | +// DON'T: Use php-aegis for Blade escaping |
| 148 | +{{ $content }} // Blade auto-escapes, don't use aegis |
| 149 | + |
| 150 | +// DO: Use php-aegis in non-Blade contexts |
| 151 | +$uuid = $request->input('resource_id'); |
| 152 | +if (!Validator::uuid($uuid)) { |
| 153 | + abort(400, 'Invalid resource ID'); |
| 154 | +} |
| 155 | + |
| 156 | +// DO: Use for security headers (Laravel's is less comprehensive) |
| 157 | +Headers::secure(); |
| 158 | +``` |
| 159 | + |
| 160 | +### For Vanilla PHP / APIs |
| 161 | + |
| 162 | +```php |
| 163 | +// DO: Use php-aegis as your primary security layer |
| 164 | +use PhpAegis\{Validator, Sanitizer, Headers}; |
| 165 | + |
| 166 | +// Apply security headers |
| 167 | +Headers::secure(); |
| 168 | + |
| 169 | +// Validate input |
| 170 | +if (!Validator::email($_POST['email'])) { |
| 171 | + http_response_code(400); |
| 172 | + exit(json_encode(['error' => 'Invalid email'])); |
| 173 | +} |
| 174 | + |
| 175 | +// Sanitize output |
| 176 | +echo Sanitizer::html($userContent); |
| 177 | +``` |
| 178 | + |
| 179 | +--- |
| 180 | + |
| 181 | +## Marketing Positioning |
| 182 | + |
| 183 | +### Tagline Options |
| 184 | + |
| 185 | +1. **"Security for the rest of PHP"** - Emphasizes non-framework use |
| 186 | +2. **"Where frameworks fear to tread"** - Emphasizes unique capabilities |
| 187 | +3. **"Semantic web security, done right"** - Emphasizes Turtle escaping niche |
| 188 | + |
| 189 | +### README Messaging |
| 190 | + |
| 191 | +``` |
| 192 | +php-aegis is a zero-dependency PHP security toolkit for: |
| 193 | +- API services without view layers |
| 194 | +- CLI tools and microservices |
| 195 | +- Semantic web applications (RDF/Turtle) |
| 196 | +- Any PHP app without a framework |
| 197 | +
|
| 198 | +For WordPress, use WordPress core functions. |
| 199 | +For Laravel/Symfony, use framework helpers + aegis for gaps. |
| 200 | +``` |
| 201 | + |
| 202 | +--- |
| 203 | + |
| 204 | +## Roadmap Implications |
| 205 | + |
| 206 | +Based on this positioning, prioritize: |
| 207 | + |
| 208 | +1. **RDF/Turtle escaping** - Already done, unique differentiator |
| 209 | +2. **Security headers** - Already done, fills framework gaps |
| 210 | +3. **Extended validators** - Focus on what WordPress lacks (UUID, IP, semver, etc.) |
| 211 | +4. **IndieWeb security** - Micropub, IndieAuth, Webmention (unique niche) |
| 212 | +5. **Rate limiting** - File-based, no Redis required |
| 213 | + |
| 214 | +De-prioritize: |
| 215 | +- HTML/attribute escaping improvements (frameworks do this well) |
| 216 | +- WordPress adapter (WordPress users should use WordPress functions) |
| 217 | + |
| 218 | +--- |
| 219 | + |
| 220 | +## Success Metrics |
| 221 | + |
| 222 | +| Metric | Target Audience Indicator | |
| 223 | +|--------|--------------------------| |
| 224 | +| Downloads from API/microservice projects | Primary audience | |
| 225 | +| Usage in semantic web tools | Niche but high-value | |
| 226 | +| Issues asking about WordPress | Signals need for better docs | |
| 227 | +| PRs adding framework adapters | Community wants integration | |
| 228 | + |
| 229 | +--- |
| 230 | + |
| 231 | +*This positioning reflects insights from WordPress theme (wp-sinople-theme) and plugin (Zotpress) integration attempts.* |
0 commit comments