Hello,
I use this code to generate a json output from a content.
<?php
header('Content-type: application/json; charset=utf-8');
$today = date('Y-m-d');
$data = $pages->find('veranstaltungen')->children()->visible()->filterBy('article_push', '1')->filterBy('date_event_start', '>', $today)->limit(3);
$json = [];
foreach($data as $article):
$image = $article->event_image()->toFile();
$thumbURL = $image? $image->resize(1200)->url(): '';
$imageURL = $image? $image->url(): '';
$event_date_end = "";
if($article->date_event_end()->isNotEmpty())
{
$event_date_end = date("d.m.Y",strtotime($article->date_event_end()));
}
$json[] = [
'title' => (string)$article->title(),
'event_date_start' => (string)date("d.m.Y",strtotime($article->date_event_start())),
'event_date_end' => $event_date_end,
'event_start_time' => (string)$article->start_time(),
'event_end_time' => (string)$article->end_time(),
'text' => (string)$article->text_full(),
'thumb' => $thumbURL
];
endforeach;
echo json_encode($json);
?>
If the limit is greater than 3 I get the following error:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 8192 bytes) in /home/www/web404/html/kirby/vendor/getkirby/toolkit/vendors/abeautifulsite/SimpleImage.php on line 1101
[Mon Apr 23 16:50:56 2018] [error] [client 48.188.47.75] PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /home/www/web404/html/kirby/vendor/filp/whoops/src/Whoops/Util/Misc.php on line 1
Is my code so bad ?