Skip to content
generated from bravedave/mvp

Extension for MVP

License

Notifications You must be signed in to change notification settings

bravedave/pages

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MVP - Extension

A simple extension for extending the https://github.com/bravedave/mvp.

Setting up a development project is covered in bravedave/mvp, this is just create an extension

I'm going to create the Pages extension - it will create a page and display it, allowing you to add content ...

my extension is called pages

Steps

  1. Create a development/testing environment
  2. develop and test
  3. publish - GitHub
  4. advertise - PackAGist
  5. use - composer

Recipe

Create a Development/Testing Environment

  1. Setup a new project

    composer create-project bravedave/mvp pages @dev
    cd pages
  2. Modify:

    1. the projects namespace, change the psr-4 namespace to reflect your namespace:

    composer.json

    "name": "bravedave/pages",
    "description": "Minimum Viable Product - extension",
    
    "autoload": {
         "psr-4": {
             "pages\\": "src/app/"
    
         }
    
    }
    1. add the namespace declaration to src/app/launcher.php
      • note: Parsedown is no longer "in the namespace", add the reference so you can contiue to see and use it ...
    <?php
    /**
     * David Bray
     * BrayWorth Pty Ltd
     * e. [email protected]
     *
     * MIT License
     *
    */
    
    namespace pages;
    use Parsedown;
    
    class launcher {
    1. update the reference in _www/_mvp.php
    pages\launcher::run()
  3. Update the Autoload

    composer u
  4. the src/app/ folder is going to hold our files

    1. remove all files except launcher - it is going to test your application
    2. review src/app/launcher.php
    3. You are ready to launch the application a. review the run.cmd, it will look for php in a standard location ..
    ./run.cmd

Develop and Test

  1. Create a namespaced class - src/app/page.php (see the https://github.com/bravedave/pages/blob/master/src/app/page.phpsrc/app/page.php)

    <?php
    /*
     * David Bray
     * BrayWorth Pty Ltd
     * e. [email protected]
     *
     * MIT License
     *
    */
    
    namespace pages;
    
    class page { ... }
  2. Use the class in your environment

    $page = new page;	// from this namespace
    $page->open();
    
    print 'say what you want ...';
    
    // page will self destruct and close

publish - GitHub

I've obviously publised this at https://github.com/bravedave/pages ..

advertise - PackAGist

Once published, advertise the package to composer at https://packagist.org/

use - composer

once advertised - you can use the namespaced application ..

install

composer require bravedave/pages

use

$page = new pages\page;	// from outside this namespace
$page->open();

print 'say what you want ...';

// page will self destruct and close