Skip to content

Generators

Relay provides powerful Artisan commands to scaffold API integrations quickly.

Terminal window
# Create a complete integration
php artisan make:integration GitHub --oauth --resources=Users,Repositories
# Or build piece by piece
php artisan make:connector GitHub --bearer
php artisan make:resource Users GitHub --crud --requests
php artisan make:request GetUser GitHub --method=get
CommandDescription
make:integrationScaffold complete API integration
make:connectorCreate connector class
make:requestCreate request class
make:resourceCreate resource class

Creates a complete API integration with connector, resources, requests, and directory structure.

Terminal window
php artisan make:integration {name} [options]
OptionDescription
--oauthOAuth2 authentication
--bearerBearer token authentication
--basicBasic authentication
--api-keyAPI key authentication
--cacheEnable caching
--rate-limitEnable rate limiting
--resilienceCircuit breaker & retry
--resources=Comma-separated resources
--graphqlGraphQL integration
--jsonrpcJSON-RPC integration
Terminal window
php artisan make:integration Stripe --oauth --cache
php artisan make:integration Twitter --bearer --rate-limit --resources=Users,Tweets
php artisan make:integration GitHub --graphql --bearer
Terminal window
php artisan make:connector {name} [options]
OptionDescription
--oauthOAuth2 with AuthorizationCodeGrant
--bearerBearer token authentication
--basicBasic (username/password) auth
--api-keyAPI key in header
--cacheCaching with CacheConfig
--rate-limitRate limiting with RateLimitConfig
--resilienceCircuit breaker & retry
Terminal window
php artisan make:request {name} {connector} [options]
OptionDescription
--method=HTTP method (get, post, put, patch, delete)
--jsonJSON content type
--paginatePage-based pagination
--cursorCursor-based pagination
--cacheAdd Cache attribute
--retryAdd Retry attribute
--graphqlGraphQL request
--jsonrpcJSON-RPC request
Terminal window
php artisan make:request GetUser GitHub
php artisan make:request CreateUser GitHub --method=post --json
php artisan make:request ListUsers GitHub --paginate
php artisan make:request GetUserQuery GitHub --graphql
Terminal window
php artisan make:resource {name} {connector} [options]
OptionDescription
--crudGenerate CRUD methods
--paginateAdd pagination support
--requestsAlso create request classes
Terminal window
php artisan make:resource Users GitHub --crud --requests
php artisan make:resource Posts GitHub --paginate
Terminal window
php artisan vendor:publish --tag=relay-stubs

This creates a stubs/relay/ directory where you can modify the templates.

  1. Use make:integration for new APIs - Sets up the complete structure
  2. Use --crud --requests together - Creates matching requests for resources
  3. Choose authentication upfront - Harder to change later
  4. Add rate limiting for external APIs - Prevents hitting API limits