PHP code example of bassam-nab / php-writer

1. Go to this page and download the library: Download bassam-nab/php-writer 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/ */

    

bassam-nab / php-writer example snippets



        (new PhpWriter())
            ->openClass('Models\Payment', function (PhpWriter $doc) {
                return $doc
                    ->addUse('SomeTrait')
                    ->addConstant('STATUS_PENDING', 1)
                    ->addConstant('STATUS_REJECTED', 2)
                    ->addConstant('STATUS_ACCEPTED', 3)
                    ->addLine()
                    ->addVar('payment_id')
                    ->addVar('numberOfPayments', 0, 'public', true)
                    ->addLine()
                    ->addMethod('doPay', ['$transaction_id', '...$otherOrders'], 'public', true)
                    ->addMethod('setPrice', ['$price' => 0]);
            }, 'SomeClass', ['myInterface', 'AndOtherInterface'])->exportFile();