Skip to content
Snippets Groups Projects
Commit b878a7f2 authored by Raphaël's avatar Raphaël
Browse files

It works now

parent 56fa10db
No related merge requests found
......@@ -9,7 +9,7 @@ RUN mkdir -p $COMPOSER_HOME && chmod -R 777 $COMPOSER_HOME && curl -sS https://g
&& chmod +x composer.phar && mv composer.phar /usr/local/bin/composer
RUN mkdir /srv/app
COPY vhost.conf /etc/apache2/sites-available/000-default.conf
COPY .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
RUN docker-php-ext-install pdo pdo_mysql bcmath && \
chown -R www-data:www-data /srv/app && \
......
/vendor/
*.swp
<?php
use Tp1\Hello\Controllers\HelloWorldController;
$app->get('/', HelloWorldController::class, ':handle');
$app->get('/', HelloWorldController::class . ':handle');
?>
......@@ -7,6 +7,11 @@
"twig/twig": "^3.0",
"slim/twig-view": "^3.1"
},
"autoload": {
"psr-4": {
"Tp1\\Hello\\": "src/"
}
},
"license": "PGMAGGPL",
"authors": [
{
......
<?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Tp1\Hello\Controllers\HelloWorldController;
use Slim\Factory\AppFactory;
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../app/routes.php';
$app = AppFactory::create();
require __DIR__ . '/../app/routes.php';
$app->run();
i<?php
<?php
namespace Tp1\Hello\Controllers;
namespace Tp1\Hello\Controllers\HelloWorldController;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use Tp1\Hello\Models\Voiture;
use Psr\Http\Message\RequestInterface as Request;
use Psr\Http\Message\ResponseInterface as Response;
use Slim\Views\Twig;
class HelloWorldController
{
public function handle (RequestInterface $request, ResponseInterface $response, $args) {
public function handle (Request $request, Response $response, $args) {
$twig = Twig::create(__DIR__ . '/../../views', [ 'cache' => false ]);
return $twig->render($response, 'accueil.tpl', [
'voiture' => 'bonjour',
'voiture' => new Voiture('Renault'),
'error' => 'Could not connect to database'
]);
}
}
?>
<?php
namespace Tp1\Hello\Models;
class Voiture {
private $marque;
public function __construct(string $marque) {
$this->marque = $marque;
}
public function getMarque(): string {
return $this->marque;
}
}
?>
<link href='css/hello.css' rel='stylesheet' type='text/css' />
<html>
<head>
<link rel="stylesheet" href="stylesheets/hello.css">
</head>
<body>
<h1>Hello {{ voiture.marque }}</h1>
</body>
</html>
<h1>Hello <span> World </span></h1>
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