Connect with us

PhpStorm 2019.1 Provides Blade Debugging Support and a Laravel Code Style Preset

kizinho

Published

on

Follow
NEWS: PhpStorm 2019.1 Provides Blade Debugging Support and a Laravel Code Style Preset [New  Developer] » Naijacrawl
Photo: Naijacrawl
site

JetBrains announced the release of PhpStorm 2019.1.This week with debugging support for Blade (and Twig) templates and a new predefined Laravel code style configuration.

 

Upgrade your Laravel applications to Laravel 5.8 and get XDebug ready to start debugging Laravel Blade templates in PhpStorm 2019.

 

Thanks to a Laravel 5.8 contribution for including the Laravel 5.8 Blade Template File Path in compiled templates, now you can set a breakpoint directly in a blade file instead of having to search for the compiled template and setting a breakpoint: Another Laravel-related feature in PhpStorm 2019.1 is a predefined Laravel code style setting.

 

You can configure it for your project from the preferences menu — Settings > Editor > Code Style > PHP and then select “set from > Predefined Style > Laravel”:

 

If you want to get a quick overview of what’s new, check out this video from JetBrains: The official PhpStorm blog has a PhpStorm 2019.1 release announcement post with all the details of the release.

site


kizinho

I am a software developer, like meeting people and love blogging, that's why I developed naijacrawl because that's what I love doing.

Continue Reading
Click To Comment

BE First To Comment


    Leave a Reply

    Your email address will not be published. Required fields are marked *

    How to Integrate Flutterwave Rave Payment System in your Laravel Applications

    kizinho

    Published

    on

    DEVELOPER PROGRAMMING: How to Integrate Flutterwave Rave Payment System in your Laravel Applications [New  Developer Programming] » Naijacrawl
    Photo: Naijacrawl

    Hi Folks, I know many laravel developers that have been using Paystack as their payment system have been finding it difficult to integrate Paystack Laravel Package from Laravel 6.0 - 7.0 versions. Today I have a beautiful solution by using Flutterwave Rave Payment System, this process will work on any laravel versions.

    Requirements

    1. Running Exiting Project on Laravel
    2. Create Account on Flutterwave
    3. Then you are good to go

    Lets Begin

    composer require kingflamez/laravelrave
    

    Once Flutterwave Rave for Laravel is installed, you need to register the service provider. Open up config/app.php and add the following to the providers key.

    'providers' => [
     /* * Package Service Providers... */
     ... 
    KingFlamez\Rave\RaveServiceProvider::class, 
    ...
    ]
    

    Also add this to the aliases

    'aliases' => [
     ... 
    'Rave' => KingFlamez\Rave\Facades\Rave::class, 
    ...
    ]
    

    Configuration

    Publish the configuration file using this command:

    php artisan vendor:publish
     --provider="KingFlamez\Rave\RaveServiceProvider"

    Usage

    Open your .env file and add your public key, secret key, environment variable and logo url like so:

    RAVE_PUBLIC_KEY=FLWPUBK_TEST
    -xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx-X
    RAVE_SECRET_KEY=FLWSECK_TEST-xxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxx-XRAVE_TITLE="Naijacrawl"
    RAVE_ENVIRONMENT="staging"
    RAVE_LOGO="https://rave.flutterwave.com/
    static/img/[email protected]"
    RAVE_PREFIX="rave"
    • RAVE_PUBLIC_KEY - This is the api public key gotten from your dashboard (compulsory)
    • RAVE_SECRET_KEY - This is the api secret key gotten from your dashboard (compulsory)
    • RAVE_TITLE - This is the title of the modal (optional)
    • RAVE_ENVIRONMENT - This can be staging or live. Staging API keys can be gotten here while live API keys can be gotten here (compulsory)
    • RAVE_LOGO - This is a custom logo that will be displayed on the modal (optional)
    • RAVE_PREFIX - This is a the prefix added to your transaction reference generated for you (optional)
    • SECRET_HASH - This is the secret hash for your webhook, this is necessary if you are setting up a recurrent payment


    1. Setup Routes


    Route::post('/pay', '[email protected]')
    ->name('pay');
    Route::post('/rave/callback',
     '[email protected]')->name('callback');
    


    2. Grant CSRF Access to Rave Callback


    Go to app/Http/Middleware/VerifyCsrfToken.php 

    and add your callback url to the $except array

    protected $except = [ 'rave/callback'];
    

    A sample form from your frontend will look like so:

    @php
    $array = array(array(
    'metaname' => 'color',
     'metavalue' => 'blue'),
     array('metaname' => 'size',
     'metavalue' => 'big'));
    @endphp
    
    "POST" action="{{ route('pay') }}" id="paymentForm"> {{ csrf_field() }} type="hidden" name="amount" value="500" />type="hidden" name="payment_method" value="both" />type="hidden" name="description" value="Beats by Dre. 2017" />type="hidden" name="country" value="NG" />type="hidden" name="currency" value="NGN" />type="hidden" name="email" value="[email protected]" />type="hidden" name="firstname" value="Oluwole" />type="hidden" name="lastname" value="Adebiyi" />type="hidden" name="metadata" value="{{ json_encode($array) }}" >type="submit" value="Buy" />

    In this implementation, we are expecting a form encoded POST request to this script. The request will contain the following parameters.

    • payment_method Can be card, account, both
    • description Your transaction description
    • logo Your logo url
    • title Your transaction title
    • country Your transaction country
    • currency Your transaction currency
    • email Your customer's email
    • firstname Your customer's firstname
    • lastname Your customer's lastname
    • phonenumber Your customer's phonenumber
    • ref Your transaction reference.
    • It must be unique per transaction.
    • By default, the Rave class generates
    • a unique transaction reference for each
    • transaction. Pass this parameter only if
    • you uncommented the related section in
    • the script below.

    3. Setup your Controller

    Setup your controller to handle the routes. I created the RaveController.

    Use the Rave facade.


    Example


    namespaceApp\Http\Controllers;
    use Illuminate\Http\Request;
    //use the Rave Facadeuse Rave;class RaveController extends Controller{ 
    /** * Initialize Rave payment process * @return void */ 
    public function initialize() {
     //This initializes payment and redirects to the payment gateway 
    //The initialize method takes the parameter of the redirect URL
     Rave::initialize(route('callback')); 
    } 
    /** * Obtain Rave callback information 
    * @return void */public function callback() {
     $data =Rave::verifyTransaction(request()->txref);
    dd($data); 
    // view the data response 
     if ($data->status == 'success') {
     //do something to your database
    }else
     {
    //return invalid payment
    }
     }
    }
    



    Continue Reading

    Laravel Absolute Beginners Masterclass

    kizinho

    Published

    on

    DEVELOPER PROGRAMMING: Laravel Absolute Beginners Masterclass [New  Developer Programming] » Naijacrawl
    Photo: Naijacrawl

    Hi, folks you are welcome to laravel absolute beginner masterclass, if you are here to learn how laravel works, I will recommend you to visit laravel website here but if you are here to use laravel build a product, you are very welcome. Laravel is a PHP Framework

    What is a Framework?

    Before I dive into explaining Laravel, you will need to understand what is a framework. In general, a Framework is a set of conceptual structure and guidelines, used to build a useful product without so much stress.

    What Laravel 

    Laravel is a web application framework with an expressive, elegant syntax which aims to make the development process a pleasing one for the developer without sacrificing application functionality. Laravel follows the MVC (Model View Controller) structure which makes it easy to learn and rapidly prototype the web applications

    Installation

    1. PHP version from 7.2.5 and above
    2. Composer
    3. I will make use of latest laravel version 7.13 for this

    How to Install PHP

    Visit this link to download Xampp for your PHP, download based on your OS and install it.

    How to install Composer

    Visit this link to download composer for your OS, for window user click here, After downloading install the composer, you need to select the path for your PHP, the composer will alert you during the installation on windows.


    To check if your PHP and composer are successfully installed, open your command (cmd) and type PHP -v, you will see a screen like this

    PHP 7.3.5 (cli) (built: May 1 2019 13:17:17) ( ZTS MSVC15 (Visual C++ 2017) x64 )

    Copyright (c) 1997-2018 The PHP Group

    Zend Engine v3.3.5, Copyright (c) 1998-2018 Zend Technologies


    Check for composer type on your cmd composer, a list of a variable will appear on the screen

    Laravel Installation Completion

    Laravel utilizes Composer to manage its dependencies. So, before using Laravel, make sure you have Composer installed on your machine.

    First, download the Laravel installer using Composer:

    composer global require laravel/installer
    

    Creating a new project using - Create-Project

    1. first, go to your composer, the local disk you will see xampp -> htdocs-> create a new folder, right on the folder by holding shift + right click and follow the step below
    2. Install Laravel by issuing the Composer create-project command in your terminal:
    composer create-project --prefer-dist laravel/laravel SampleSite

    You have successfully installed your first project using laravel.

    Continue Reading

    How to show a nice message to the user when an error occurs in using Guzzle with Laravel

    kizinho

    Published

    on

    DEVELOPER PROGRAMMING: How to show a nice message to the user when an error occurs in using Guzzle with Laravel [New  Developer Programming] » Naijacrawl
    Photo: Naijacrawl

    Hi Folks, have you encountered an ugly Exception when making a post, get, put, delete to external API when an error like 500 or 404 occurs. Today you are at the right place, after reading this you will be able to show a nice message to your users in case of any of those errors occurs

    When making a request to external API using guzzle to solve this problem you will need to catch the Exception by following the steps below.

    1. Prepare your request using Guzzle, I believe you know or have set it up already
    2. Make a post or get request to your external API
        public function create(Request $request) {
        $input = $request->all();
        try {
            $client = new Client();
            $headers = ['API-Key' => env('API_KEY')];
            $url = 'api/post/create';
            $response = $client->request('POST', $url, ['headers' => $headers, 'query' => $input]);
            $res = json_decode($response->getBody());
    //here will catch error to aviod ugly message to users  
        } catch (\GuzzleHttp\Exception\RequestException $res) {
            if ($res->hasResponse()) {
                $response = $res->getResponse();
                if ($response->getStatusCode() == 500) {
                    abort(500);
                } if ($response->getStatusCode() == 404) {
                    abort(404);
                }
            }
        }
    }
    


    Congrats , you have saved your users from seeing that ugly message . Share and comment

    Continue Reading

    Latest