Download the PHP package dg/twitter-php without Composer

On this page you can find all versions of the php package dg/twitter-php. 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 twitter-php

X for PHP

Downloads this Month Tests Latest Stable Version License

Small and easy-to-use library for the X (formerly Twitter) API v2.

Installation

Install via Composer:

Requirements: PHP 8.2 or higher.

Getting API Keys

  1. Go to X Developer Portal
  2. Sign in and create a Developer account (Free tier is sufficient)
  3. Create a new Project and App

  4. Set up permissions (important!):

    • App Settings → User authentication settings → Edit
    • App permissions: Read and Write
    • Type of App: Web App
    • Callback URI: https://localhost/callback (placeholder, not used)
    • Website URL: any valid URL
  5. Generate keys:

    • Keys and tokens → API Key and Secret → Generate
    • Keys and tokens → Access Token and Secret → Generate

    ⚠️ Note: After changing permissions, you must regenerate the Access Token!

  6. Use case description (required by X, min. 250 characters):

Usage

Create the client using your API credentials:

Note: The Free tier of the X API only allows sending and deleting tweets and reading your own profile (authenticate()). Reading timelines, searching, user info, followers and other read endpoints require the Basic tier or higher.

Sending Tweets

With an image:

With multiple images:

Timelines

Get your own tweets:

Get your home timeline (you and people you follow):

Get your mentions:

Displaying Tweets

The static method Client::clickable() makes links, mentions and hashtags in tweets clickable:

Searching

Users

Social Actions

Authentication

Test if user credentials are valid:

Custom API Requests

You can call any X API v2 endpoint directly:

Error Handling

All methods throw DG\X\Exception on error:

Backward Compatibility

The old class names DG\Twitter\Twitter, DG\Twitter\Exception, Twitter and TwitterException are available as aliases for DG\X\Client and DG\X\Exception.

Support Me

Buy me a coffee

Thank you!

Changelog

v5.0 (2/2026)

v4.1 (11/2019)

v4.0 (2/2019)

v3.8 (2/2019)

v3.7 (3/2018)

v3.6 (8/2016)

v3.5 (12/2014)

v3.4 (11/2014)

v3.3 (3/2014)

v3.2 (1/2014)

v3.1 (3/2013)

v3.0 (12/2012)

v2.0 (8/2012)

v1.0 (7/2008)


(c) David Grudl, 2008, 2026 (https://davidgrudl.com)


All versions of twitter-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.2
ext-json Version *
guzzlehttp/guzzle Version ^7.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 dg/twitter-php contains the following files

Loading the files please wait ...