Download the PHP package antogkou/laravel-oauth2-client without Composer

On this page you can find all versions of the php package antogkou/laravel-oauth2-client. 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 laravel-oauth2-client

Laravel OAuth2 Client

Tests Packagist

A robust Laravel package for OAuth2 Client Credentials flow integration with automatic token management.

Features

Installation

Publish configuration file:

Configuration

Config File (config/oauth2-client.php)

Environment Variables

Enabling IDE Autocompletion for Services

To enable IDE autocompletion for your OAuth2 service names in OAuth2::for('...'), this package provides a type generation command:

This command scans your config/oauth2-client.php and generates a PHP interface listing all configured service names. IDEs like PHPStorm and VSCode (with PHP Intelephense) will then offer autocompletion and static analysis for the available services.

Workflow:

  1. Add or update your services in config/oauth2-client.php under the services key.
  2. Run php artisan oauth2:generate-types to regenerate the types.
  3. Enjoy autocompletion in your IDE for OAuth2::for('your_service').

Example:

After running the command, your IDE will suggest 'service1' and 'service2' in:

Usage

Basic API Calls

Request Options

The package supports various request options that can be passed as an array:

JSON Payload

Form Data

Multipart/Form-Data (File Uploads)

Custom Headers

Available Methods

Response Handling

Error Handling

The package throws Antogkou\LaravelOAuth2Client\Exceptions\OAuth2Exception for errors:

Automatic JSON Error Responses

To make error handling seamless, you can configure your Laravel application's global exception handler to automatically return JSON responses for OAuth2 errors. This way, users of your API will always receive a structured JSON error response, and you don't need to manually catch exceptions in your controllers.

How to set up:

  1. Open (or create) app/Exceptions/Handler.php in your Laravel application.
  2. Add the following to your render method:

Debug Mode:

Example error response (with debug):

This setup is optional but highly recommended for API projects using this package.

Testing

The package uses Pest PHP for testing. To run all tests:

To run only unit tests:

To run static analysis:

To check code style:

To test the artisan type generation command:

Adding New Services for Testing:

Troubleshooting & FAQ

Q: I added a new service but it doesn't autocomplete in my IDE.

Q: I get an exception about missing or invalid service configuration.

Q: How do I test error handling or simulate network/cache failures?

Q: How do I contribute tests or features?

Contributing

Contributions welcome! Please follow:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a pull request

License

MIT License - See LICENSE for details.

Support

For issues and feature requests, please create a GitHub issue.


All versions of laravel-oauth2-client with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2|^8.3|^8.4
laravel/framework Version ^11.0|^12.0
guzzlehttp/guzzle Version ^7.8
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 antogkou/laravel-oauth2-client contains the following files

Loading the files please wait ....