Download the PHP package siberfx/x-autopost without Composer

On this page you can find all versions of the php package siberfx/x-autopost. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package x-autopost

X Autopost for Laravel

Connect one X account to your Laravel app and post your models to X automatically when they go live, or whenever you choose. Posts go through X's API (POST /2/tweets): the title, an optional description and the link, kept within X's 280-character limit.

Requires PHP 8.4+ and Laravel 12 or 13.

Contents

Quick start

Open the settings page, click Connect X, run php artisan queue:work, and publish an article: it is posted to X.

1. Set up the X app

  1. Create a project and app in the X developer portal (https://developer.x.com/en/portal/dashboard). Posting needs an access tier that allows POST /2/tweets.
  2. User authentication settings: enable OAuth 2.0, choose the app type (a Web App with a client secret, or a Native/Public app for PKCE only) and the permissions Read and write.
  3. Callback URI / Redirect URL: add your callback URL exactly, e.g. https://example.com/x/callback (scheme, host, path, no trailing slash). Add one per environment.
  4. Copy the Client ID and, for a confidential app, the Client Secret.

Scopes requested: tweet.read tweet.write users.read offline.access. offline.access gives the refresh token that keeps the connection alive without asking the admin again.

2. Install

x:install options: --theme=bootstrap (no question asked) and --headless (no UI, see section 9). It publishes config/x-autopost.php and the two migrations, writes X_UI_THEME (or X_UI=false) to .env when missing, and prints the callback URL to register.

Using UUID or ULID keys? Edit the published create_x_posts_table migration: replace morphs('shareable') with uuidMorphs('shareable') / ulidMorphs('shareable') before migrating.

Required: say who may manage X. Connecting, disconnecting, seeing the connection and sharing are all guarded by the manage-x-autopost gate. The package defines it to deny everyone until your app defines it. Any rule works:

The routes sit behind ['web', 'auth', 'can:manage-x-autopost']. Change the middleware, the URL prefix or the page you come back to in config/x-autopost.php:

Changing the prefix changes the callback URL: register the new one on your X app.

3. Connect

Send an admin to route('x-autopost.redirect'). After X's consent screen they land on after_connect with ?x=…:

?x= Meaning
connected Done.
cancelled The person cancelled on X.
error&reason=… X refused, e.g. a scope the app does not have.
exchange_failed The code could not be exchanged; the reason is in your log. Usually a callback URL mismatch.
invalid_state The login attempt expired or was replayed. Connect again.
missing_code X came back without an authorization code. Connect again.
not_configured X_CLIENT_ID is missing.

Check the connection anywhere:

connection() asks X (GET /2/users/me) at most once every status_cache_ttl seconds (300 by default). isConnected() only checks that a token is stored and never calls X.

Tokens. The access token lasts about two hours. When X answers 401 the package refreshes it with the refresh token and retries once; X rotates the refresh token on every refresh, so both are stored each time. If the refresh is refused too, the connection shows as expired and the admin must connect again.

4. Make a model shareable

The post always fits X's limit: the link counts as 23 characters, and the description is shortened with an ellipsis to make room. A custom commentary whose text cannot fit even without its description throws InvalidArgumentException when shared, so the post is not sent.

XPost Limit Default
make(string $url, string $title) title cut to 200 characters —
->description(string) shortened to fit the 280 characters empty
->commentary(string $template) must fit 280 characters "{title}\n\n{description}\n\n{url}"
->text() the final post text —

XPost is immutable: each method returns a copy.

With X_AUTOPOST=true, an Article is queued for X when it is created published or changes from draft to published, once. Editing a published article does not post again. Seeders and Artisan commands do not auto-post (set autopost.in_console to allow it). Auto-post reacts to model saves through Eloquent events, so mass update() queries and saveQuietly() do not auto-post.

Run a queue worker. The job is dispatched after the database transaction commits, is unique per model while it waits, and retries 3 times when X is busy or unreachable (429, 5xx, network). A request X refuses outright (401 after a failed refresh, 403, 422 …) or an invalid post fails at once.

5. Share on demand

share() throws NotConnected, NotShareable (not live), XRequestFailed (X's message) or InvalidArgumentException (an invalid URL or a text that does not fit). A post X accepted without returning its id is recorded as posted with a null post_id.

6. Ready-made admin UI

With Livewire installed the same components are available as <livewire:x-autopost.connection /> and <livewire:x-autopost.share-button :model="$article" />. Every action checks the gate; people it refuses see the connection read-only and the share button disabled.

The theme comes from X_UI_THEME (tailwind or bootstrap). For a custom look, publish the views (vendor:publish --tag=x-autopost-views) and point ui.theme at your own folder of views.

Tailwind v4 needs the package classes compiled:

7. Commands and events

Command Does
x:install Publishes config and migrations, chooses the theme.
x:status Shows the connected account and its status.
x:disconnect Revokes the token at X and forgets it.
x:share {model} {id} Shares one model now.
x:check-token Fires TokenExpired when X no longer accepts the connection. Schedule it daily.
x:test-notification Sends a test message to the enabled notification channels.
Event Fired when
Connected The account is connected.
Disconnected The connection is removed; revoked tells whether X confirmed it.
Shared A post went out (shareable, post).
ShareFailed An automatic share gave up.
TokenExpired x:check-token found X refusing the connection.

8. Notifications

Messages go to Telegram, Slack and/or email when a post goes out, an automatic share gives up, or X stops accepting the connection. They are off until you switch them on:

Messages are queued by default (X_NOTIFY_QUEUED=false sends them at once). A failing channel never fails the share. Add your own channel by implementing Siberfx\XAutopost\Contracts\NotificationChannel and listing it under notifications.channels.

9. Headless: no UI

Headless mode registers no views, Blade or Livewire components; the routes answer JSON only. Connect an admin with a link to route('x-autopost.redirect'), then use the facade, events and endpoints:

10. Configuration reference

Key Env Default
client_id X_CLIENT_ID —
client_secret X_CLIENT_SECRET null (public app)
redirect_uri X_REDIRECT_URI the package callback route
scopes — tweet.read tweet.write users.read offline.access
routes.prefix / routes.name — x / x-autopost.
routes.middleware — ['web', 'auth', 'can:manage-x-autopost']
routes.after_connect — /
autopost.enabled X_AUTOPOST false
autopost.in_console — false
autopost.queue_connection / queue — the defaults
ui.enabled X_UI true
ui.theme X_UI_THEME tailwind
notifications.enabled X_NOTIFY false
token_store — DatabaseTokenStore
http.timeout — 20 seconds
job.tries / job.backoff — 3 / [60, 300]
status_cache_ttl — 300 seconds

11. Troubleshooting

Testing your app

License

MIT. See LICENSE.


All versions of x-autopost with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
guzzlehttp/guzzle Version ^7.8
illuminate/auth Version ^12.0|^13.0
illuminate/bus Version ^12.0|^13.0
illuminate/cache Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/encryption Version ^12.0|^13.0
illuminate/events Version ^12.0|^13.0
illuminate/filesystem Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/log Version ^12.0|^13.0
illuminate/mail Version ^12.0|^13.0
illuminate/queue Version ^12.0|^13.0
illuminate/routing Version ^12.0|^13.0
illuminate/session Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
illuminate/view Version ^12.0|^13.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package siberfx/x-autopost contains the following files

Loading the files please wait ...