Seteo inicial
This commit is contained in:
28
composer.json
Normal file
28
composer.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"name": "provm/publivia",
|
||||||
|
"descripcion": "Pagina web para PubliVia",
|
||||||
|
"type": "project",
|
||||||
|
"require": {
|
||||||
|
"slim/slim": "^4",
|
||||||
|
"nyholm/psr7": "^1",
|
||||||
|
"nyholm/psr7-server": "^1",
|
||||||
|
"php-di/slim-bridge": "^3",
|
||||||
|
"rubellum/slim-blade-view": "^0",
|
||||||
|
"nesbot/carbon": "^2"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "^8",
|
||||||
|
"kint-php/kint": "^3"
|
||||||
|
},
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Aldarien",
|
||||||
|
"email": "aldarien85@gmail.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"ProVM\\Publivia\\Common\\": "common"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
public/.htaccess
Normal file
4
public/.htaccess
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
RewriteEngine On
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
|
RewriteRule ^ index.php [QSA,L]
|
8
public/index.php
Normal file
8
public/index.php
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
$__environment = 'web';
|
||||||
|
include_once implode(DIRECTORY_SEPARATOR, [
|
||||||
|
dirname(__DIR__),
|
||||||
|
'setup',
|
||||||
|
'app.php'
|
||||||
|
]);
|
||||||
|
$app->run();
|
2
resources/routes/router.php
Normal file
2
resources/routes/router.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
include_once . '.php';
|
14
resources/routes/web.php
Normal file
14
resources/routes/web.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
$folder = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
__DIR__,
|
||||||
|
'web'
|
||||||
|
]);
|
||||||
|
if (file_exists($folder)) {
|
||||||
|
$files = new DirectoryIterator($folder);
|
||||||
|
foreach ($files as $file) {
|
||||||
|
if ($file->isDir()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
include_once $file->getRealPath();
|
||||||
|
}
|
||||||
|
}
|
5
resources/views/layout/base.blade.php
Normal file
5
resources/views/layout/base.blade.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="es">
|
||||||
|
@include('layout.head')
|
||||||
|
@include('layout.body')
|
||||||
|
</html>
|
9
resources/views/layout/body.blade.php
Normal file
9
resources/views/layout/body.blade.php
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<body>
|
||||||
|
@include('layout.header')
|
||||||
|
<div class="ui container">
|
||||||
|
<div class="ui basic segment">
|
||||||
|
@yield('page_content')
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@include('layout.footer')
|
||||||
|
</body>
|
1
resources/views/layout/footer.blade.php
Normal file
1
resources/views/layout/footer.blade.php
Normal file
@ -0,0 +1 @@
|
|||||||
|
@include('layout.scripts')
|
5
resources/views/layout/head.blade.php
Normal file
5
resources/views/layout/head.blade.php
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<head>
|
||||||
|
<meta charset="utf8" />
|
||||||
|
<title>@yield('page_title')</title>
|
||||||
|
@include('layout.styles')
|
||||||
|
</head>
|
3
resources/views/layout/header.blade.php
Normal file
3
resources/views/layout/header.blade.php
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
<header class="ui container">
|
||||||
|
@include('layout.menu')
|
||||||
|
</header>
|
4
resources/views/layout/menu.blade.php
Normal file
4
resources/views/layout/menu.blade.php
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
<nav class="ui menu">
|
||||||
|
<a class="item" href="{}">Inicio</a>
|
||||||
|
<a class="item" href="{}/create">Crear</a>
|
||||||
|
</nav>
|
13
resources/views/layout/scripts.blade.php
Normal file
13
resources/views/layout/scripts.blade.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
@if (isset($assets->scripts))
|
||||||
|
@foreach ($assets->scripts as $script)
|
||||||
|
<script type="text/javascript" src="{{$script}}"></script>
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(() => {
|
||||||
|
@stack('global_script')
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
@stack('scripts')
|
16
resources/views/layout/styles.blade.php
Normal file
16
resources/views/layout/styles.blade.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
@if (isset($assets->styles))
|
||||||
|
@foreach ($assets->styles as $style)
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{$style}}" />
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
@if (isset($assets->fonts))
|
||||||
|
@foreach ($assets->fonts as $font)
|
||||||
|
<link href="{{$font}}" />
|
||||||
|
@endforeach
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@stack('styles')
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
@stack('global_style')
|
||||||
|
</style>
|
60
setup/app.php
Normal file
60
setup/app.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
use DI\ContainerBuilder as Builder;
|
||||||
|
use DI\Bridge\Slim\Bridge;
|
||||||
|
|
||||||
|
if (!isset($__environment)) {
|
||||||
|
throw new Exception('Missing __environment variable');
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once 'composer.php';
|
||||||
|
|
||||||
|
$builder = new Builder();
|
||||||
|
|
||||||
|
$files = [
|
||||||
|
'config',
|
||||||
|
'setup'
|
||||||
|
];
|
||||||
|
$folders = [
|
||||||
|
'common',
|
||||||
|
$__environment
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($files as $file) {
|
||||||
|
foreach ($folders as $folder) {
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
__DIR__,
|
||||||
|
$folder,
|
||||||
|
$file . '.php'
|
||||||
|
]);
|
||||||
|
if (file_exists($filename)) {
|
||||||
|
$builder->addDefinitions($filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$container = $builder->build();
|
||||||
|
$app = Bridge::create($container);
|
||||||
|
try {
|
||||||
|
$app->setBasePath($container->get('base_url'));
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($folders as $folder) {
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
__DIR__,
|
||||||
|
$folder,
|
||||||
|
'middleware.php'
|
||||||
|
]);
|
||||||
|
if (file_exists($filename)) {
|
||||||
|
include_once $filename;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
$container->get('folders')->routes,
|
||||||
|
'router.php'
|
||||||
|
]);
|
||||||
|
if (!file_exists($filename)) {
|
||||||
|
throw new Exception('Missing router file.');
|
||||||
|
}
|
||||||
|
include_once $filename;
|
22
setup/common/config.php
Normal file
22
setup/common/config.php
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'base_url' => dirname(__DIR__),
|
||||||
|
'urls' => function() {
|
||||||
|
$arr = [];
|
||||||
|
$arr['base'] = '/provm/demos/provm';
|
||||||
|
return (object) $arr;
|
||||||
|
},
|
||||||
|
'folders' => function() {
|
||||||
|
$arr = [];
|
||||||
|
$arr['base'] = dirname(__DIR__, 2);
|
||||||
|
$arr['resources'] = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
$arr['base'],
|
||||||
|
'resources'
|
||||||
|
]);
|
||||||
|
$arr['routes'] = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
$arr['resources'],
|
||||||
|
'routes'
|
||||||
|
]);
|
||||||
|
return (object) $arr;
|
||||||
|
}
|
||||||
|
];
|
10
setup/composer.php
Normal file
10
setup/composer.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
$filename = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
dirname(__DIR__)
|
||||||
|
'vendor'
|
||||||
|
'autoload.php'
|
||||||
|
])
|
||||||
|
if (!file_exists($filename)) {
|
||||||
|
throw new Exception('Missing composer install.');
|
||||||
|
}
|
||||||
|
include_once $filename;
|
34
setup/web/config.app
Normal file
34
setup/web/config.app
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
use Psr\Container\ContainerInterface as Container;
|
||||||
|
|
||||||
|
return [
|
||||||
|
'folders' => DI\decorate(function($prev, Container $c) {
|
||||||
|
$arr = (array) $prev;
|
||||||
|
$arr['templates'] = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
$prev->resources,
|
||||||
|
'views'
|
||||||
|
]);
|
||||||
|
$arr['cache'] = implode(DIRECTORY_SEPARATOR, [
|
||||||
|
$prev->base,
|
||||||
|
'cache'
|
||||||
|
]);
|
||||||
|
return (object) $arr;
|
||||||
|
}),
|
||||||
|
'assets' => (object) [
|
||||||
|
'styles' => [
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/semantic.min.css'
|
||||||
|
],
|
||||||
|
'scripts' => [
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/semantic.min.js'
|
||||||
|
],
|
||||||
|
'fonts' => [
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/brand-icons.woff',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/brand-icons.woff2',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/icons.woff',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/icons.woff2',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/outline-icons.woff',
|
||||||
|
'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.6/themes/default/assets/fonts/outline-icons.woff2'
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
16
setup/web/setup.php
Normal file
16
setup/web/setup.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
use Psr\Container\ContainerInterface as Container;
|
||||||
|
|
||||||
|
return [
|
||||||
|
ProVM\Common\Alias\View::class => function(Container $c) {
|
||||||
|
return new ProVM\Common\Define\View(
|
||||||
|
$c->get('folders')->templates,
|
||||||
|
$c->get('folders')->cache,
|
||||||
|
null,
|
||||||
|
[
|
||||||
|
'urls' => $c->get('urls'),
|
||||||
|
'assets' => $c->get('assets')
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
];
|
Reference in New Issue
Block a user