This file provides guidance for Claude, Cursor, and other AI assistants working with the Owlstack Laravel codebase.
Owlstack Laravel is the official Laravel integration for the Owlstack social media publishing platform. It wraps Owlstack Core with Laravel-idiomatic services: a service provider, facade, config file, and event bridging.
- Repository:
owlstack/owlstack-laravel - Language: PHP 8.1+
- Framework: Laravel 10.x, 11.x, 12.x
- Core dependency:
owlstack/owlstack-core^1.0 - Namespace:
Owlstack\Laravel\ - License: MIT
This package is a thin wrapper. All platform logic, formatting, HTTP transport, and content models live in owlstack-core. This package provides:
- Service Provider — Wires core classes into Laravel's container
- Facade — Static access via
Owlstack::telegram(...) - Configuration —
config/owlstack.phppopulated from.env - Event Bridge — Routes core events through Laravel's event dispatcher
Rule: If a change involves platform behavior, API communication, or content formatting, it belongs in owlstack-core. If it involves Laravel integration (DI, config, artisan, queues), it belongs here.
src/
├── Events/
│ └── LaravelEventDispatcher.php # Bridges core events → Laravel events
├── Facades/
│ └── Owlstack.php # Facade for SendTo
├── OwlstackServiceProvider.php # Registers all services
└── SendTo.php # High-level publishing API
config/
└── owlstack.php # Publishable config (credentials, platforms)
tests/
├── TestCase.php # Base test case (extends Orchestra Testbench)
├── Unit/
│ ├── SendToTest.php
│ └── ServiceProviderTest.php
├── Feature/
│ └── PublishingTest.php
└── fixtures/ # Test fixture files
examples/
└── laravel-12/ # Example Laravel 12 app
- PHP version: 8.1+ — use named arguments, enums, readonly properties, constructor promotion, union types where appropriate.
- Strict types: Every PHP file must start with
declare(strict_types=1);. - Code style: Follow PSR-12 coding standards.
- Type hints: All method parameters and return types must be fully typed. Use
mixedonly when truly necessary. - DocBlocks: Use PHPDoc for complex parameter types (
@param array{key: type}) and@throwsannotations. Skip trivial docblocks where the type signature is self-explanatory. - Naming conventions:
- Classes:
PascalCase - Methods/properties:
camelCase - Constants:
UPPER_SNAKE_CASE - Config keys:
snake_case
- Classes:
The OwlstackServiceProvider registers these bindings:
| Binding | Resolves To | Lifetime |
|---|---|---|
OwlstackConfig |
Config built from config/owlstack.php |
Singleton |
HttpClientInterface |
Core's cURL HttpClient (with optional proxy) |
Singleton |
HashtagExtractor |
Core's hashtag extraction utility | Singleton |
CharacterTruncator |
Core's text truncation utility | Singleton |
TelegramFormatter, TwitterFormatter, FacebookFormatter |
Platform-specific formatters (using HashtagExtractor + CharacterTruncator) |
Singleton |
| Platform instances | TelegramPlatform, TwitterPlatform, FacebookPlatform, RedditPlatform, DiscordPlatform, SlackPlatform, InstagramPlatform, PinterestPlatform, WhatsAppPlatform, TumblrPlatform, LinkedInPlatform |
Singleton (only if credentials present) |
PlatformRegistry |
Registry of all active platforms | Singleton |
EventDispatcherInterface |
LaravelEventDispatcher |
Singleton |
Publisher |
Core's Publisher with event dispatcher |
Singleton |
'owlstack' / SendTo |
SendTo instance |
Singleton |
SendTo provides shorthand methods for each platform:
$sendTo->telegram('Hello!'); // Text message
$sendTo->twitter('Tweet!'); // Tweet
$sendTo->facebook('Post!', 'link', $data); // Facebook post
$sendTo->toAll($post); // Publish to all platformsEach method internally creates a Post, selects the platform from the registry, and delegates to Publisher::publish().
LaravelEventDispatcher implements core's EventDispatcherInterface and forwards events through Laravel's Illuminate\Events\Dispatcher:
// Core fires: PostPublished, PostFailed
// Laravel listeners can listen normally:
Event::listen(PostPublished::class, fn($e) => ...);.env variables → config/owlstack.php → OwlstackConfig → Platform constructors
Only platforms with valid credentials are instantiated and registered.
# Install dependencies
composer install
# Run all tests
./vendor/bin/phpunit
# Run only unit tests
./vendor/bin/phpunit --testsuite=Unit
# Run only feature tests
./vendor/bin/phpunit --testsuite=Feature
# Shortcut
composer test- Tests use Orchestra Testbench to boot a minimal Laravel app.
- Mock
HttpClientInterfaceto avoid real API calls. - Unit tests verify service registration and
SendTomethod behavior. - Feature tests verify end-to-end publishing flow with mocked HTTP.
- Test environment config is in
tests/.env.testing.
- Create the command class in
src/Console/. - Register it in
OwlstackServiceProvider::boot()using$this->commands([...]). - Add tests in
tests/Feature/.
- Add the key to
config/owlstack.phpwith a sensible default. - Read it in
OwlstackServiceProviderwhen building the relevant service. - Document it in
README.md.
- Create a
PublishJobinsrc/Jobs/. - Add a
queue()orlater()method toSendTo. - Use Laravel's
dispatch()to push the job.
- Never duplicate platform logic from
owlstack-core— always delegate. - Never hardcode API URLs or credentials.
- Never commit real API tokens or
.envfiles. - Never suppress errors with the
@operator. - Never use
var_dump,print_r, ordd()in production code. - Never break backward compatibility without a major version bump.
- Never add middleware or routes without making them opt-in via config.