articlai/articlai-laravel

Package to allow blog publishing in Laravel using Articlai

v1.0.0 2025-07-21 19:18 UTC

This package is auto-updated.

Last update: 2025-07-21 21:08:17 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A Laravel package that enables seamless integration with ArticlAI's Custom API connection type. This package provides secure API endpoints that allow ArticlAI to create, update, and delete blog posts in your Laravel application.

Installation

You can install the package via composer:

composer require articlai/articlai-laravel

You can publish and run the migrations with:

php artisan vendor:publish --tag="articlai-laravel-migrations"
php artisan migrate

You can publish the config file with:

php artisan vendor:publish --tag="articlai-laravel-config"

Configuration

After publishing the config file, update your .env file with your ArticlAI settings:

# Authentication Method (api_key, bearer_token, or basic_auth)
ARTICLAI_AUTH_METHOD=api_key
ARTICLAI_API_KEY=your-secret-api-key

API Endpoints

The package provides the following endpoints for ArticlAI integration:

Validation Endpoint

GET /api/articlai/validate

Returns platform information and validates the connection.

Content Management

POST /api/articlai/posts          # Create a new post
GET /api/articlai/posts/{id}      # Get a specific post
PUT /api/articlai/posts/{id}      # Update a post
DELETE /api/articlai/posts/{id}   # Delete a post

Usage

Using the Service Class

use Articlai\Articlai\Articlai;

$articlai = app(Articlai::class);

// Create a post
$post = $articlai->createPost([
    'title' => 'My Blog Post',
    'content' => '<p>This is the content</p>',
    'excerpt' => 'Post excerpt',
    'status' => 'published'
]);

// Update a post
$updatedPost = $articlai->updatePost($post->id, [
    'title' => 'Updated Title'
]);

// Get posts
$posts = $articlai->getPosts(['status' => 'published']);

Using the Facade

use Articlai\Articlai\Facades\Articlai;

$post = Articlai::createPost([
    'title' => 'My Blog Post',
    'content' => '<p>This is the content</p>'
]);

Using the Model Directly

use Articlai\Articlai\Models\ArticlaiPost;

$post = ArticlaiPost::create([
    'title' => 'My Blog Post',
    'content' => '<p>This is the content</p>',
    'status' => 'published'
]);

// Get published posts
$publishedPosts = ArticlaiPost::published()->get();

Command Line Interface

Check the package status and view recent posts:

php artisan articlai:status --posts=10

Testing

composer test

Credits

License

The MIT License (MIT). Please see License File for more information.