Skip to content

Instantly share code, notes, and snippets.

@hh-com
Last active December 13, 2018 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hh-com/31f3fdacbf919ce30e8589e436f0b5a6 to your computer and use it in GitHub Desktop.
Save hh-com/31f3fdacbf919ce30e8589e436f0b5a6 to your computer and use it in GitHub Desktop.
Boilerplate: Contao3- Run Singlefile without Module (by Cron)
<?php
/**
######### Dont forget to create a .htaccess in the same direcotry from this file ###########
<IfModule !mod_authz_core.c>
Order allow,deny
Allow from all
</IfModule>
<IfModule mod_authz_core.c>
Require all granted
</IfModule>
######### ^^ Dont forget to create a .htaccess in the same direcotry from this file ^^ ###########
**/
define('TL_MODE', 'FE');
define('BYPASS_TOKEN_CHECK', true);
/*Cache-Control:*/
header("Cache-Control: no-cache, must-revalidate"); //HTTP 1.1
header("Pragma: no-cache"); //HTTP 1.0
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
// Include the Contao initialization script
// ++++++ !!!CHECK PATH!!! ++++++
if (file_exists('../../../initialize.php')) {
// Regular way
/** @noinspection PhpIncludeInspection */
require_once('../../../initialize.php');
} else {
// Try composer location (see #1136)
/** @noinspection PhpIncludeInspection */
require_once('../../../../../../../../system/initialize.php');
}
class runWithoutModule extends \Controller
{
/**
* Must be defined cause parent is protected.
*/
public function __construct() {}
/*
* Run this script
*/
public function run()
{
echo "do something";
}
}
$runReminder = new runWithoutModule();
$runReminder->run();
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div class="container-fluid">
<div class="row">
<div class="col-xs-6">
<h1>Output for something</h1>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment