I am working from Cockpit CMS and I am trying to create a blog using this tutorial.
Directory structure (simplified):
+blog
-index.php
+ views
-index.php
-article.php
-index.php
+partials
-constants.php
-top.php
blog/index:
<?php require_once("../partials/errorlogging.php"); ?>
<?php require_once("../partials/constants.php"); ?>
<?php require_once("../partials/top.php"); ?>
<?php
$app = new Lime\App();
// bind routes
$app->bind("/", function() use($app) {
$posts = collection('blog')->find(["public"=>true])->sort(["created"=>1])->toArray();
return $app->render('views/index.php', ['posts' => $posts]);
});
$app->bind("/article/:id", function($params) use($app) {
$post = collection('blog')->findOne(["_id"=>$params['id']]);
return $app->render('views/article.php', ['post' => $post]);
});
$app->run();
?>
<?php require_once("../partials/bottom.php"); ?>
blog/views/index.php:
<?php require_once("../../partials/errorlogging.php"); ?>
<?php require_once("../../partials/constants.php"); ?>
<?php require_once("../../partials/top.php"); ?>
<?php foreach ($posts as $post): ?>
<h2><a href="<?php $this->route('/article/'.$post['_id']);?>"><?php=$post['title'];?></a></h2>
<?php endforeach; ?>
<?php require_once("../../partials/bottom.php"); ?>
blog/views/article.php:
<?php require_once("../../partials/errorlogging.php"); ?>
<?php require_once("../../partials/constants.php"); ?>
<?php require_once("../../partials/top.php"); ?>
<h1><?php=$post['title'];?></h1>
<p>
<?php=$post['content'];?>
</p>
<?php require_once("../../partials/bottom.php"); ?>
Now at the moment if I go to domain.name/blog/ I receive this error:
{"type":64,"message":"require_once(): Failed opening required '..\/..\/partials\/errorlogging.php' (include_path='.:\/home\/codio\/.parts\/packages\/php5-apache2\/5.5.15\/lib\/php')","file":"\/home\/codio\/workspace\/blog\/views\/index.php","line":1}
However I know for a fact that it is not a problem with the require methods because if I run this code inblog/index.php:
<?php require_once("../../partials/errorlogging.php"); ?>
<?php require_once("../../partials/constants.php"); ?>
<?php require_once("../../partials/top.php"); ?>
<?php
$app = new Lime\App();
$app->bind("/", function() {
return "Hello World!";
});
$app->run();
?>
<?php require_once("../../partials/bottom.php"); ?>
There is absolutely no errors on the page or console, and "Hello World" is printed to the screen, so it is to do with the blog/index.php syntax but I have no idea where the problem is...