Download the PHP package upcoach/upstart-for-laravel without Composer
On this page you can find all versions of the php package upcoach/upstart-for-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download upcoach/upstart-for-laravel
More information about upcoach/upstart-for-laravel
Files in upcoach/upstart-for-laravel
Package upstart-for-laravel
Short Description Get started developing apps quickly for the upcoach platform with this package.
License MIT
Homepage https://github.com/upcoach/upstart-for-laravel
Informations about the package upstart-for-laravel
Get started developing apps quickly for the upcoach platform with this package.
This package provides a starting point for developing applications for the upcoach platform. It contains useful components, such as an API client, request validation, and webhook controllers, to help you get started smoothly.
Features
Installation and Webhook Management
To use this package with upcoach, you will need to provide an Installation URL and a Webhook URL in the upcoach developer portal.
This package provides two endpoints in the routes/api.php
file to handle these URLs automatically:
POST /api/upcoach-install
POST /api/upcoach-webhooks:
To set up your application, use the following URLs:
https://your-application-address.com/api/upcoach-install
for the Installation URL.https://your-application-address.com/api/upcoach-webhooks
for the Webhook URL.
Middleware for upcoach Requests
To validate incoming requests from upcoach, you can use the Upcoach\UpstartForLaravel\Http\Middleware\EnsureUpcoachRequestIsValid
middleware. This middleware will validate the signature of the request, and if it is valid, it will add the installation to the request object.
API Client
Once the app is installed, an installation request is initiated that includes an API token. This token is saved in the database through the installation model, along with other relevant information. You can utilize this token to access the required API endpoints (scoped to the installed organization) when querying the upcoach API.
Here's how you can use the provided upcoach API client:
Or if you are using the Upcoach\UpstartForLaravel\Http\Middleware\EnsureUpcoachRequestIsValid
middleware, you can access the installation via the request object:
Then you can use the upcoach API client to query the API:
Getting Started
To get started with this package, you will need to follow these steps:
- Sign up for the upcoach developer program on the upcoach developer portal.
- Create a new application on the developer portal.
-
Install the package using the following command:
-
Publish the configuration and migration files by running this command:
- Configure your Laravel application by adding the following details to your .env file:
You can find these details in the developer information section of your application on the developer portal.
Usage
- Complete the Getting Started steps above.
- Create a new block on the developer portal.
- Create a new route in your application to handle the block.
-
Add the
Upcoach\UpstartForLaravel\Http\Middleware\EnsureUpcoachRequestIsValid
middleware to the route. - Create a new controller for the route.
Developer Mode & Testing
This package provides features to help you test your application without having to install it on the upcoach app.
Enabling Developer Mode
- To enable developer mode, you can set the UPCOACH_DEVELOPER_MODE environment variable. When developer mode is enabled, the Client class is replaced with FakeClient, and API calls are mocked. For more information, refer to the
Upcoach\UpstartForLaravel\Mocks\FakeClient
class.
Simulating upcoach Requests
- You can use the
upstart:simulate
artisan command to simulate upcoach requests. This command supports interactive mode, where you can answer the questions directly in the console. Run the following command to start the interactive mode:
Alternatively, you can simulate a request directly by providing the required options. Here's an example:
You can also provide a payload for overriding the default payload parameters:
This command is also useful for testing settings pages:
After running the upstart:simulate
command, it will display the URL that you can open in your browser to simulate the request. Additionally, it will output the full command, including all payload parameters, which you can use directly from the console for subsequent requests without having to answer the questions and obtain the same URL.
Troubleshooting
CSRF Token Mismatch
If you are getting a CSRF Token Mismatch
error in the upcoach app, you can fix it by adding the following code to the app/Http/Middleware/VerifyCsrfToken.php
file:
This will set the SameSite
attribute of the CSRF cookie to None
and set the Secure
attribute to true
. This will allow the upcoach app to send the CSRF cookie to your application. Otherwise, the upcoach app will not be able to send the CSRF cookie to your application in the iframe due to the SameSite
attribute being set to Lax
by default.
Testing
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- upcoach
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of upstart-for-laravel with dependencies
guzzlehttp/guzzle Version ^7.5.1
illuminate/contracts Version ^9.0|^10.0
spatie/laravel-package-tools Version ^1.15.0
spatie/url-signer Version ^2.0.2