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
- Create a development/testing environment
- develop and test
- publish - GitHub
- advertise - PackAGist
- use - composer
-
Setup a new project
composer create-project bravedave/mvp pages @dev cd pages
-
Modify:
- 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/" } }
- 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 {
- update the reference in _www/_mvp.php
pages\launcher::run()
-
Update the Autoload
composer u
-
the src/app/ folder is going to hold our files
- remove all files except launcher - it is going to test your application
- review src/app/launcher.php
- You are ready to launch the application a. review the run.cmd, it will look for php in a standard location ..
./run.cmd
-
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 { ... }
-
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
I've obviously publised this at https://github.com/bravedave/pages ..
Once published, advertise the package to composer at https://packagist.org/
once advertised - you can use the namespaced application ..
install
composer require bravedave/pagesuse
$page = new pages\page; // from outside this namespace $page->open(); print 'say what you want ...'; // page will self destruct and close