PHP code example of jenky / transmit

1. Go to this page and download the library: Download jenky/transmit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jenky / transmit example snippets


use Illuminate\Http\Client\Request;
use Illuminate\Support\Facades\Http;

Http::fake();

Http::client('my_client')->get('foo');

Http::client('my_client')->assertSent(function (Request $request) {
    //
});

Http::client('my_client')->assertNotSent(function (Request $request) {
    //
});
 bash
php artisan vendor:publish
 bash
php artisan vendor:publish --provider="Jenky\Transmit\TransmitServiceProvider"
 php
'default' => [
    'tap' => [
        App\Http\Client\CustomizeRequest::class,
    ],
],
 php


namespace App\Http\Client;

use Illuminate\Http\Client\PendingRequest;

class CustomizeRequest
{
    /**
     * Customize the given client pending request instance.
     *
     * @param  \Illuminate\Http\Client\PendingRequest  $request
     * @return void
     */
    public function __invoke(PendingRequest $request)
    {
        $request->withToken('my_access_token');
    }
}
 php


namespace App\Http\Client;

use GuzzleHttp\MessageFormatter;
use GuzzleHttp\Middleware;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Log\LogManager;

class UseLogger
{
    /**
     * The logger manager instance.
     *
     * @var \Illuminate\Log\LogManager
     */
    protected $logger;

    /**
     * Create new log middleware instance.
     *
     * @param  \Illuminate\Log\LogManager $logger
     * @return void
     */
    public function __construct(LogManager $logger)
    {
        $this->logger = $logger;
    }

    /**
     * Customize the given client pending request instance.
     *
     * @param  \Illuminate\Http\Client\PendingRequest  $request
     * @param  string|null  $channel
     * @param  string  $level
     * @return void
     */
    public function __invoke(PendingRequest $request, ?string $channel = null, string $level = 'debug')
    {
        $request->withMiddleware(Middleware::log(
            $this->logger->channel($channel), new MessageFormatter, $level
        ));
    }
}
 php
'my_client' => [
    'tap' => [
        function (PendingRequest $request) {
            $request->asForm();
        },
    ],
],