added some stuff
This commit is contained in:
parent
b4738b0718
commit
93e3348b41
40
app/bootstrap.php
Normal file
40
app/bootstrap.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
use Slim\Factory\AppFactory;
|
||||||
|
use DI\Container as Container;
|
||||||
|
use Psr\Http\Message\ResponseInterface as Response;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
|
|
||||||
|
require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
|
||||||
|
$container = new Container;
|
||||||
|
|
||||||
|
$settings = require __DIR__ . '/../app/settings.php';
|
||||||
|
$settings($container);
|
||||||
|
|
||||||
|
// Set view in Container
|
||||||
|
$container->set('view', function() {
|
||||||
|
return Twig::create(__DIR__ . '/../templates',
|
||||||
|
['cache' => __DIR__ . '/../cache']);
|
||||||
|
});
|
||||||
|
|
||||||
|
AppFactory::setContainer($container);
|
||||||
|
|
||||||
|
$app = AppFactory::create();
|
||||||
|
|
||||||
|
$middleware = require __DIR__ . '/../app/middleware.php';
|
||||||
|
$middleware($app);
|
||||||
|
|
||||||
|
// Routes
|
||||||
|
$app->get('/', function (Request $request, Response $response, $args) {
|
||||||
|
$response->getBody()->write("Hello Nick!");
|
||||||
|
return $response;
|
||||||
|
});
|
||||||
|
|
||||||
|
$app->get('/twig', function (Request $request, Response $response, $args) {
|
||||||
|
return $this->get('view')->render($response, 'hello.twig', [
|
||||||
|
'name' => $args['name']
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
$app->run();
|
16
app/middleware.php
Normal file
16
app/middleware.php
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?php //middleware
|
||||||
|
use Slim\App;
|
||||||
|
|
||||||
|
return function(App $app) {
|
||||||
|
$setting = $app->getContainer()->get('settings');
|
||||||
|
|
||||||
|
$app->addErrorMiddleware(
|
||||||
|
$setting['displayErrorDetails'],
|
||||||
|
$setting['logErrors'],
|
||||||
|
$setting['logErrorDetails']
|
||||||
|
);
|
||||||
|
|
||||||
|
// Add Twig-View Middleware
|
||||||
|
$app->add(TwigMiddleware::createFromContainer($app));
|
||||||
|
|
||||||
|
};
|
13
app/settings.php
Normal file
13
app/settings.php
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
return function(ContainerInterface $container) {
|
||||||
|
$container->set('settings', function() {
|
||||||
|
return [
|
||||||
|
'displayErrorDetails' => true,
|
||||||
|
'logErrorDetails' => true,
|
||||||
|
'logErrors' => true
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
@ -3,7 +3,7 @@
|
|||||||
# check that $1 folder does not exit
|
# check that $1 folder does not exit
|
||||||
[ -d "$1" ] && echo "Folder $1 already exists" && exit 1
|
[ -d "$1" ] && echo "Folder $1 already exists" && exit 1
|
||||||
|
|
||||||
echo "*** Starting New Laravel Project ***"
|
echo "*** Starting New Slim Project ***"
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Check composer installed
|
# Check composer installed
|
||||||
@ -16,34 +16,46 @@ if [[ $COMPOSER -ne 0 ]]; then
|
|||||||
echo 'Checkout how to Install Composer here: https://www.nickyeoman.com/blog/php/install-composer-on-ubuntu/'
|
echo 'Checkout how to Install Composer here: https://www.nickyeoman.com/blog/php/install-composer-on-ubuntu/'
|
||||||
echo 'Once installed, try running this script again'
|
echo 'Once installed, try running this script again'
|
||||||
exit 1
|
exit 1
|
||||||
else
|
|
||||||
composer create-project laravel/laravel $1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir $1
|
||||||
cd $1
|
cd $1
|
||||||
|
|
||||||
# Not running rootless, in development mode:
|
|
||||||
chmod -R 777 storage/
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Create directories
|
# Create directories
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
mkdir sass
|
mkdir sass templates
|
||||||
mkdir -p public/css
|
mkdir -p public/css
|
||||||
|
# TODO: public index.php file
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Composer
|
# Composer
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
composer require slim/slim:"4.*"
|
||||||
|
composer require slim/psr7
|
||||||
|
composer require slim/twig-view
|
||||||
|
composer require nickyeoman/nytwig
|
||||||
|
composer require nickyeoman/sassLibrary
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Docker
|
||||||
|
################################################################################
|
||||||
|
echo "Creating a docker-compose"
|
||||||
|
wget https://raw.githubusercontent.com/nickyeoman/phpframework/main/docker/docker-compose.yml
|
||||||
|
|
||||||
|
echo "Creating a Dockerfile"
|
||||||
|
wget https://raw.githubusercontent.com/nickyeoman/phpframework/main/docker/Dockerfile
|
||||||
|
|
||||||
|
wget -O .env https://raw.githubusercontent.com/nickyeoman/phpframework/main/env.sample
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Git
|
# Git
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
git init
|
git init
|
||||||
echo '.sass-cache/' >> .gitignore
|
#echo '.sass-cache/' >> .gitignore
|
||||||
git add .
|
git add .
|
||||||
git commit -m"First Commit, slim installed"
|
git commit -m"First Commit, slim installed"
|
||||||
|
|
||||||
|
2
public/index.php
Normal file
2
public/index.php
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
<?php
|
||||||
|
require '../app/bootstrap.php';
|
Reference in New Issue
Block a user