Commit 1912e06f authored by Webserver User's avatar Webserver User

1.0.3

parent 617906ec
# 1.0.0
## notes
Initial commit simple-mvc
Perhaps the simplest and easiest MVC framework in the world.
## added
* complete framework
## fixed
-
## removed
-
\ No newline at end of file
MIT License
Copyright (c) 2019 Heiko Mettelsiefen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
......@@ -6,9 +6,10 @@ Perhaps the simplest and easiest PHP MVC framework in the world.
* tidy, easy to understand and easy to use
* strict separation between code and view
* supports composer, just load what you need
* page creator, create pages with controller and view fully automatically and iteratively
# next features
* page creator, create pages with controller and view fully automatically and iteratively
# documenation
https://gitlab.com/mascoda/simple-mvc/wikis/home
......
......@@ -15,7 +15,8 @@
},
"autoload": {
"psr-4": {
"HM\\":"classes/"
"HM\\":"models/",
"simple\\":"simplemvc/"
}
}
}
<?
$page->title = 'console';
$page->template('custom');
/* How to create a new page
* create a new page included controller and views
*
* first step, define the page / url
*
*/
$url = "/items/item";
/*
* second step, build a MVC object with the uri as parameter
* !Note: do not use the variable $page to create new pages, this will overwrite the current object
*/
$newPage = new HM\MVC($url);
/*
* third step, create page
* this will generated follow files:
*
* /controller/blog.controller.php
* /render/views/blog.view.php (maybe for the list of all articles)
* /render/views/blog/article.view.php (a single blog post)
*
*/
#$newPage->create();
<?
$page->title = 'simple-mvc';
$page->template('default');
$page->template('custom');
/* How to create a new page
......@@ -9,12 +9,12 @@ $page->template('default');
* first step, define the page / url
*
*/
$url = "/items/item";
$url = "/catalog/list/item";
/*
* second step, build a MVC object with the uri as parameter
* !Note: do not use the variable $page to create new pages, this will overwrite the current object
*/
$newPage = new HM\MVC($url);
$newPage = new simple\MVC($url);
/*
* third step, create page
......@@ -25,4 +25,5 @@ $newPage = new HM\MVC($url);
* /render/views/blog/article.view.php (a single blog post)
*
*/
#$newPage->create();
\ No newline at end of file
# $newPage->create();
......@@ -3,7 +3,7 @@ require __DIR__ . '/globals/header.php';
require __DIR__ . '/globals/settings.php';
require __DIR__ . '/vendor/autoload.php';
$page = new HM\MVC($_SERVER["SCRIPT_URL"]);
$page = new simple\MVC($_SERVER["SCRIPT_URL"]);
# show info about the $page object
# var_dump($page);
......
<main role="main" class="flex-shrink-0">
<div class="container">
<h1 class="mt-5">console.view.php</h1>
<p class="lead">Console: </p>
<p class="card"><pre><? var_dump($newPage) ?></pre></p>
</div>
</main>
<?
namespace HM;
namespace simple;
use HM;
class MVC {
/**
......@@ -148,7 +149,7 @@ namespace HM;
$pages = explode('/', rtrim(ltrim($this->page, '/'),'/'));
// create directories for the views recursively
$viewDirectory = new Dir(dirname(dirname(__DIR__) . '/render/views/' . $this->page));
$viewDirectory = new HM\Dir(dirname(dirname(__DIR__) . '/render/views/' . $this->page));
if (!$viewDirectory->exists()) :
$viewDirectory->create($mode = 0775, $recursive = true);
endif;
......@@ -160,13 +161,13 @@ namespace HM;
$page = new MVC($page);
// create controller
$controller = new File(dirname(__DIR__) . '/controller/' . $page->page .'.controller.php');
$controller = new HM\File(dirname(__DIR__) . '/controller/' . $page->page .'.controller.php');
if (!$controller->exists()) :
$controller->write(SRC::getContent('controller', 'default.controller.php'));
endif;
// create views
$view = new File(dirname(__DIR__) . '/render/views/' . $path_to . $page->page . '.view.php');
$view = new HM\File(dirname(__DIR__) . '/render/views/' . $path_to . $page->page . '.view.php');
if (!$view->exists()) :
$view->create($mode = 0755);
$view->write(SRC::getContent('views', 'default.view.php'));
......
<?
namespace HM;
namespace simple;
class SRC {
/**
......
......@@ -6,8 +6,8 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'HM\\Dir' => $baseDir . '/classes/Dir.class.php',
'HM\\File' => $baseDir . '/classes/File.class.php',
'HM\\MVC' => $baseDir . '/classes/MVC.class.php',
'HM\\SRC' => $baseDir . '/classes/SRC.class.php',
'HM\\Dir' => $baseDir . '/models/Dir.class.php',
'HM\\File' => $baseDir . '/models/File.class.php',
'simple\\MVC' => $baseDir . '/simplemvc/MVC.class.php',
'simple\\SRC' => $baseDir . '/simplemvc/SRC.class.php',
);
......@@ -6,5 +6,6 @@ $vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'HM\\' => array($baseDir . '/classes'),
'simple\\' => array($baseDir . '/simplemvc'),
'HM\\' => array($baseDir . '/models'),
);
......@@ -7,6 +7,10 @@ namespace Composer\Autoload;
class ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c
{
public static $prefixLengthsPsr4 = array (
's' =>
array (
'simple\\' => 7,
),
'H' =>
array (
'HM\\' => 3,
......@@ -14,17 +18,21 @@ class ComposerStaticInitc9276e89b85b1a7c62ea9fd02827598c
);
public static $prefixDirsPsr4 = array (
'simple\\' =>
array (
0 => __DIR__ . '/../..' . '/simplemvc',
),
'HM\\' =>
array (
0 => __DIR__ . '/../..' . '/classes',
0 => __DIR__ . '/../..' . '/models',
),
);
public static $classMap = array (
'HM\\Dir' => __DIR__ . '/../..' . '/classes/Dir.class.php',
'HM\\File' => __DIR__ . '/../..' . '/classes/File.class.php',
'HM\\MVC' => __DIR__ . '/../..' . '/classes/MVC.class.php',
'HM\\SRC' => __DIR__ . '/../..' . '/classes/SRC.class.php',
'HM\\Dir' => __DIR__ . '/../..' . '/models/Dir.class.php',
'HM\\File' => __DIR__ . '/../..' . '/models/File.class.php',
'simple\\MVC' => __DIR__ . '/../..' . '/simplemvc/MVC.class.php',
'simple\\SRC' => __DIR__ . '/../..' . '/simplemvc/SRC.class.php',
);
public static function getInitializer(ClassLoader $loader)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment