PHP code example of shudd3r / skeletons

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

    

shudd3r / skeletons example snippets


  namespace Shudd3r\Skeletons;
  
  use Shudd3r\Skeletons\Environment\Files\Directory\LocalDirectory;
  
  $args = new InputArgs($argv);
  
  $package  = new LocalDirectory(get_cwd());
  $template = new LocalDirectory(__DIR__ . '/template');
  $app      = new Application($package, $template);
  

  use Shudd3r\Skeletons\Replacements\Replacement;
  
  $app->replacement('package.name')->add(new Replacement\PackageName());
  $app->replacement('repository.name')->add(new Replacement\RepositoryName('package.name'));
  $app->replacement('package.description')->add(new Replacement\PackageDescription('package.name'));
  $app->replacement('namespace.src')->add(new Replacement\SrcNamespace('package.name'));
  

  use Shudd3r\Skeletons\Replacements\Replacement\GenericReplacement;
  
  $default  = fn () => '[email protected]';
  $validate = fn (string $value) => $value === filter_var($value, FILTER_VALIDATE_EMAIL);
  
  $app->replacement('author.email')
      ->add(new GenericReplacement($default, $validate, null, 'Your email address', 'email'));
  

  $app->replacement('author.email')
      ->build(fn () => '[email protected]')
      ->argumentName('email')
      ->inputPrompt('Your email address')
      ->validate(fn (string $value) => $value === filter_var($value, FILTER_VALIDATE_EMAIL));
  

  use Shudd3r\Skeletons\Templates\Contents;
  use Shudd3r\Skeletons\Templates\Template;
  
  $app->template('composer.json')->createWith(
      fn (Contents $contents) => new Template\MergedJsonTemplate(
          new Template\BasicTemplate($contents->template()),
          $contents->package(),
          $args->command() === 'update'
      )
  );
  

  $exitCode = $app->run($args);
  exit($exitCode);
  

$app->replacement('namespace.src')->add(new Replacement\SrcNamespace());