PHP code example of vahid / respond

1. Go to this page and download the library: Download vahid/respond 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/ */

    

vahid / respond example snippets


$app->register(Vahid\Respond\RespondServiceProvider::class);


if ( ! function_exists('config_path'))
{
    /**
     * Get the configuration path.
     *
     * @param  string $path
     * @return string
     */
    function config_path($path = '')
    {
        return app()->basePath() . '/config' . ($path ? '/' . $path : $path);
    }
}
 php
Vahid\Respond\RespondServiceProvider::class,
 php
'Respond' => Vahid\Respond\Facades\Respond::class,
bash
$ php artisan config:publish vahid/respond
bash
$ php artisan vendor:publish --provider="Vahid\Respond\Providers\RespondServiceProvider"
json
"autoload": {
    "psr-4": {
        "App\\": "app/"
    },
    "files": [
        "app/Helpers/GeneralHelpers.php"
    ]
},
 php
Respond::succeed( $data );
 php
Respond::deleteSucceeded();
 php
Respond::updateSucceeded();
 php
Respond::insertSucceeded();
 php
Respond::deleteFailed();
 php
Respond::updateFailed();
 php
Respond::insertFailed();
 php
Respond::notFound();
 php
Respond::connectionRefused();
 php
Respond::wrongParameters();
 php
Respond::methodNotAllowed();
 php
Respond::requestFailedNotFound();
 php
Respond::validationErrors( $data );
 php
Respond::setStatusCode( 200 )->setStatusText( 'succeed' )->respondWithMessage( 'Your custom message' );