PHP code example of codemagpie / class-generator

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

    

codemagpie / class-generator example snippets


$config = new Config(
            dirname(__DIR__), // project directory path
            DeclareTypeModel::INNER, // default inner, outer: Will be in the class attribute comments above statement; inner: Inside the class declaration attributes
            PropertyModel::SMALL_HUMP, // default small_hump, underline: Properties of keys into underline; small_hump: Properties of keys into a small hump
            Person::class, // The generated object will extend the class
            [DanceInterface::class], // The generated object will implement this interfaces
            [PlayTrait::class], // The generated object will use this traits
            'Nest', // Nested objects directory suffix
            '', // default bash path .php-cs-fixer.php, cs-fixer config file
        );
ClassGeneratorBuilder::create($config)->gen([
    'name' => 'test',
    'age' => 12,
    'score' => 80.5,
    'teacher' => [
         'name' => 'wang',
     ],
     'hobby' => ['ping-pong'],
     'choose_classes' => [[
         'name' => 'math',
     ]],
], 'src/Model', 'Student');