Problem with preparing array with attendance for team

I got Users, Absences and Reasons tables:

Users
id | name 

Absences
id | user_id:foreignKey | reason_id:foreignKey | deputy_id:foreignKey | start:date | end:date

Reasons
id | name

I got attendance calendar which looks like:

Day   | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-----------------------------------------------|
User1 | o | o | V | V | S | S | o | o | o | V  |
-----------------------------------------------|
User2 | T | o | o | o | H | V | o | V | o | V  |
-----------------------------------------------|

Where “V” is Vacation, “S” sick etc. I want to print each User attendance report in that table.

@foreach ($users as $user )
   <tr>
      <td> {{ $user->name }} </td>
   @if($user->absences != null)
      @foreach($days as $day)
         @foreach ($user->absences as $absence)
           @if($day >= $absence->start->format('d') && $day <= $absence->end->format('d'))
              // there check if $user->absence->reason_id == something ...
           @else
              
           @endif
         @endforeach
       @endforeach
    @endif
  </tr>
@endforeach

Also I want to have a tooltip, where I print specific data for each day (reason name, deputy name).

I have no idea how to get the range between two dates in each absence, merge it to got f.e table of user absence days with another array with reason.:

[
  2 => ['reason_id => 1, deputy_id = 3], 
  3 => ['reason_id => 1, deputy_id = 3], 
  7 => ['reason_id => 2, deputy_id = 1]
]

Where keys [2,3,7] are the days of the absence.

Is there easier way to achieve that or should I rebuild the database structure?

Add image to PHP email template

If I add the following line into the template the checkout becomes unavailable.

"n<img src="https://example.com/images/girocode.png" alt="GiroCode" />" . 

How can I make the work in PHP?

Prepared statement always returns true, also when (previously registered) username is not found in database

next block is located in class that inherits database class,connect() is my method for connecting to a database

protected function checkUser($username){
    $searchForUser=$this->connect()->prepare('select username from users where username=?;');

    if($searchForUser->execute(array($username))){
        $searchForUser=null;
        header("location: ../login.php?error=existing_username");
        exit();
    }

    $check=false;
    if($searchForUser->rowCount()>0){
        $check=true;
    }
    return $check;
}

next block is from class that inherits a class above

private function checkForUserExistance(){
    $value = false;
    if($this->checkUser($this->username)){
        $value=true;
    }
    return $value;
}

how to solve the undefined property problem in laravel 8.7

I develop a forum module for a web site IN LARAVEL 8, I face the problem of Undefined property: AppModelsThread::$title, since 3 days I look for the solution but in vain.
Here is the code of my model

<?php
  namespace AppModels;
  use AppTraitsHasAuthor;
  use AppTraitsHasTags;
  use IlluminateDatabaseEloquentBuilder;
  use IlluminateDatabaseEloquentFactoriesHasFactory;
  use IlluminateDatabaseEloquentModel;
  use IlluminateDatabaseEloquentRelationsBelongsTo;
  use IlluminateSupportStr;
  class Thread extends Model
 {
use HasTags;
use HasAuthor;
use HasFactory;
const TABLE = 'threads';
protected $table = self::TABLE;
protected $fillable = [
    'title',
    'body',
    'slug',
    'writer_id',
    'category_id',
];
protected $with = [
    'category',
    'writer',
    'tags',];
public function category(): BelongsTo
{
    return $this->belongsTo(Category::class);
}

public function excerpt(int $limit = 250): string
{
    return Str::limit(strip_tags($this->body()), $limit);
}

public function id(): int
{
    return $this->id;
}

public function title(): string
{
    return $this->title;
}

public function body(): string
{
    return $this->body;
}

public function slug(): string
{
    return $this->slug;
}

public function delete()
{
    $this->removeTags();
    parent::delete();
}
public function scopeForTag(Builder $query, string $tag): Builder
{
    return $query->whereHas('tagsRelation', function ($query) use ($tag) {
        $query->where('tags.slug', $tag);
    });
}

code of my Controller that displays the details of the post (show)

public function show(Category $category, Thread $thread)
{
  return view('pages.threads.show', compact('thread', 'category'));
}

the different fragments of the views

  • Index

      @foreach($threads as $thread)
                         <article class="post post-medium">
                             <div class="row mb-3">
                                 <div class="col-lg-5">
                                     <div class="post-image thumb-info-wrapper border-radius-0">
                                         <a href="blog-post.html">
                                             <img src="{{asset('assets/frontend//img/blog/medium/blog-11.jpg')}}" class="img-fluid img-thumbnail img-thumbnail-no-borders rounded-0" style="width: 100px;height:100px" alt="" />
                                         </a>
                                     </div>
                                 </div>
                                 <div class="col-lg-7">
                                     <div class="post-content">
                                         <h2 class="font-weight-semibold pt-4 pt-lg-0 text-5 line-height-4 mb-2"><a href="{{ route('forums.show', [$thread->category->slug(), $thread->slug()]) }}"> {{ $thread->title() }}</a></h2>
                                         <p class="mb-0"> {{ $thread->excerpt() }}[...]</p>
                                     </div>
                                 </div>
                             </div>
                             <div class="row">
                                 <div class="col">
                                     <div class="post-meta">
                                         <span class="appear-animation"  data-appear-animation="flash" data-appear-animation-delay="0" data-appear-animation-duration="1s"><i class="far fa-calendar-alt"></i> {{ $thread->created_at->diffForHumans() }}</span>
                                         <span><i class="far fa-user"></i> By <a href="#">{{$thread->author()->name}}</a> </span>
                                         <span><i class="far fa-folder"></i> <a href="#">Lifestyle</a>, <a href="#">Design</a> </span>
                                         <span><i class="far fa-comments"></i> <a href="#">12 Comments</a></span>
                                         <a href="javascript:void(0)" class="text-muted d-inline-flex align-items-center align-middle" data-abc="true">
                                             <i class="fa fa-heart fa-spin text-danger"></i>&nbsp; <span class="align-middle">445</span> </a>
                                         <span class="text-muted d-inline-flex align-items-center align-middle ml-4">
                              <i class="fa fa-eye text-muted fsize-3"></i>&nbsp; <span class="align-middle">14532</span> </span>
                                         <span class="text-muted d-inline-flex align-items-center align-middle ml-4">
                              <i class="fa fa-comments text-muted fsize-3"></i>&nbsp; <span class="align-middle">14532</span>
                          </span>
                                         <span class="d-block d-sm-inline-block float-sm-right mt-3 mt-sm-0"><a href="{{ route('forums.show', [$thread->category->slug(), $thread->slug()]) }}" class="btn btn-xs btn-light text-1 text-uppercase">Read More</a></span>
                                     </div>
                                 </div>
                             </div>
                         </article>
                         @endforeach
    

*show

  @extends('layouts.guest')

  @section('title', 'forum')

 @push('css')

 @endpush

@section('content')
<section class="page-header page-header-modern bg-color-light-scale-1 page-header-md">
    <div class="container">
        <div class="row">
            <div class="col-md-12 align-self-center p-static order-2 text-center">
                <h1 class="text-dark font-weight-bold text-8">Medium Image Right Sidebar</h1>
                <span class="sub-title text-dark">Check out our Latest News!</span>
            </div>
            <div class="col-md-12 align-self-center order-1">
                <ul class="breadcrumb d-block text-center">
                    <li><a href="{{route('home')}}">Home</a></li>
                    <li><a href="{{route('forums.index')}}">Forum</a></li>
                    <li><a href="#">{{ $category->name() }}</a></li>
                    <li class="active">{{ $thread->title() }}</li>
                </ul>
            </div>
        </div>
    </div>
</section>
<div class="container-fluid mt-100">
    <div class="row">
        <div class="col-md-12">
            <div class="card mb-4">
                <div class="card-header">
                    <div class="media flex-wrap w-100 align-items-center"> <img src="https://i.imgur.com/iNmBizf.jpg" class="d-block ui-w-40 rounded-circle" alt="">
                        <div class="media-body ml-5"> <a href="javascript:void(0)" data-abc="true">Tom Harry</a>
                            <div class="text-muted small">13 days ago</div>
                        </div>
                        <div class="text-muted small ml-3">
                            <div>Member since <strong>01/1/2019</strong></div>
                            <div><strong>134</strong> posts</div>
                        </div>
                    </div>
                </div>
                <div class="card-body">
               <p>{!! $thread->body() !!}</p>
                </div>
                <div class="card-footer d-flex flex-wrap justify-content-between align-items-center px-0 pt-0 pb-3">
                    <div class="px-4 pt-3">
                        <a href="javascript:void(0)" class="text-muted d-inline-flex align-items-center align-middle" data-abc="true">
                            <i class="fa fa-heart fa-spin text-danger"></i>&nbsp; <span class="align-middle">445</span> </a>
                        <span class="text-muted d-inline-flex align-items-center align-middle ml-4">
                            <i class="fa fa-eye text-muted fsize-3"></i>&nbsp; <span class="align-middle">14532</span> </span>
                        <span class="text-muted d-inline-flex align-items-center align-middle ml-4">
                            <i class="fa fa-comments text-muted fsize-3"></i>&nbsp; <span class="align-middle">14532</span>
                        </span>
                    </div>
                    <div class="px-4 pt-3"> <button type="button" class="btn btn-primary"><i class="ion ion-md-create"></i>&nbsp; Reply</button> </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection


@push('js')

@endpush

thank you for your help

Is it a bad practice to send AJAX requests with always the POST HTTP method?

I was asking myself if it was a bad practice to send every ajax request I use on my Laravel 8 project with the HTTP Post method.

What I mean is that, according to Laravel 8 documentation on routing (if I understood everything well), you should use the appropriate HTTP request :

Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);

A French tutorial on the routes explains this (translated by myself) :

GET : ask for a resource that never changes,
POST : update or create a resource (often wrongly used when PUT is needed),
PUT : create or replace a resource,
PATCH : partialy update a resource,
DELETE : delete a resource.

The “problem”, if there is one, is that in my code in almost only use HTTP post requests for AJAX in my routes/web.php file, like this :

Route::post('mails/update/{id}', 'AppHttpControllersMailController@update');
Route::post('mails/sendMail/', 'AppHttpControllersMailController@sendMailTest')->name('mails.sendMailTest');
Route::post('mails/sendInstantMail/', 'AppHttpControllersMailController@sendInstantMail')->name('mails.sendInstantMail');
Route::post('mails/getRouteList/', 'AppHttpControllersMailController@getRouteList')->name('mails.getRouteList');

According to what I read, I should probably use PUT or PATCH for my update method. But with POST it works. Is it a bad practice to continue to use POST?

If I guess right, AJAX is only a way to do HTTP request, but in fact it is still the same idea behind the request, so I should change my request methods.

I am really sorry if my question is dumb, and thanks for your help!

Sources :

Laravel 8 – Route documentation about the router methods : https://laravel.com/docs/8.x/routing#available-router-methods

French tutorial on Laravel routing see “Les méthodes” chapter : https://laravel.sillo.org/cours-laravel-8-les-bases-le-routage/

English translated tutorial with Google Translate (See “The methods” chapter) : https://laravel-sillo-org.translate.goog/cours-laravel-8-les-bases-le-routage/?_x_tr_sl=fr&_x_tr_tl=en&_x_tr_hl=fr&_x_tr_pto=wapp

Cookie-Stored Setting Not Applying

I am making a setting in my WooCommerce website where the user can choose between a table view and a grid view of the products. I use cookies for this. The setting works sometimes when clicking on it; but when changing page, when there is pagination, it doesn’t always retain the selected view.

I set the cookie like this:

document.cookie = "Techsaker_se_vyval=Rutnätsvy";

And then, in my content-product.php file I check it like this:

// If products view not set to grid, show table view
if (($_COOKIE['Techsaker_se_vyval']) != 'Rutnätsvy') {

It seems the cookie value isn’t retained.

Additionally, it will sometimes also show the table view on one page of a product category, and then the grid view on a different page.

I have also observed that if I print the cookie value to the console with console.log, the value is often different from when I print it from the php with:

var_dump($_COOKIE['Techsaker_se_vyval']);

For example when I tested this, they showed conflicting values on page 1 of my shop startpage and the same values on page/2/. And I could only change the value successfully on page 2.

After further tests, I observed that the JavaScript and php sometimes do show the same value also on page 1, but even then, I couldn’t change the view on page 1. On clicking on an option, the JavaScript value in the console sometimes changes without changing the view printed, sometimes not even that. However; in a product category, as opposed to the shop startpage, I have seen that sometimes I can change the view on both page 1 and page 2.

It’s always the php value that determines what view is output. Why isn’t it always registering the same value as the JavaScript?

And changing the view always seems to work when it’s on page 2.

Does anyone know why this could be happening?

Thank you!

Why does if($x = 1 && $x == 1) throw error but if ($x == 1 && $x = 2) doesn’t in php?

In php the following code throws error:

if($x = 1 && $x == 1)

I’ve been told, it’s because && has higher precedence than =, which cases the expression to get converted to:

if($x = (1 && ($x == 1)))

So far so good, but now consider:

if $x=1; ($x == 1 && $x = 2)

This doesn’t throw error. Why doesn’t it get converted to:
if $x=1; (($x == 1) && $x) = 2)

I’ve been told thats due to = being right assosiative, but https://www.php.net/manual/en/language.operators.precedence.php says When operators have equal precedence their associativity decides how the operators are grouped.. Here we have =, && and == all being of different precedence.

P.S; My actual code is if($result != false && $res = $stmt->get_result()), which has been copied from some other reputable source, so seems like not using unneeded parenthesis is common in php.

how do I prevent form from checking at the current session?

enter image description here

enter image description here

The ones checked are the correct answer to the question. But when I click on the submit button, the questions changes and state the answers are wrong. I’ve tried too fix it by using the GET method. But that didn’t work either.

The result I am trying to get it have 3 random questions. Which are stored in an array with it’s options and answer. When the 3 questions are displayed, the options will be displayed with it. When the user clicks on the correct answer it should display the correct result, but it is not able to at the moment.

Let me include the code below.

    <?php
    /*-----------------------------------Generate 3 Random Questions ----------------------------------------- */
    /*Array Random Function*/
    $pickqns_key = array_rand($qnPool,3);
    //var_dump($pickqns_key); ----- Test if Array is sucessfully randomise with 3 questions

    /*Store 3 Question into an Array using the key generated*/
    $qns_3 = array();
    $i = 0;

    foreach($pickqns_key as $key){
        $qns_3[$i] = $qnPool[$key];
        $i++;
    }
    /*Individual Question List*/
    $question1 = $qns_3[0]["qns"];
        $q1option1 = $qns_3[0]["ops"][0];
        $q1option2 = $qns_3[0]["ops"][1];
        $q1option3 = $qns_3[0]["ops"][2];
            $q1ans = $qns_3[0]["ans"];
            var_dump($qns_3[0]);
            var_dump($q1ans);
    $question2 = $qns_3[1]["qns"];
        $q2option1 = $qns_3[1]["ops"][0];
        $q2option2 = $qns_3[1]["ops"][1];
        $q2option3 = $qns_3[1]["ops"][2];
            $q2ans = $qns_3[1]["ans"];
            var_dump($qns_3[1]);
            var_dump($q2ans);
    $question3 = $qns_3[2]["qns"];
        $q3option1 = $qns_3[2]["ops"][0];
        $q3option2 = $qns_3[2]["ops"][1];
        $q3option3 = $qns_3[2]["ops"][2];
            $q3ans = $qns_3[2]["ans"];
            var_dump($qns_3[2]);
            var_dump($q3ans);
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Final Exam</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1"><!--Please remember to change style sheet for each page-->
        <link rel= "stylesheet" href="styles/qn_History.css" type="text/css"/> 
    </head>
    <body>
        <header>
            <img class="logo" src ="source/images/nav_logo.png" alt="logo">
                <!------------Nav Bar-------------------->
                <nav>
                <ul class ="nav__links">
                  <li><a href="index.php">Home</a></li>
                  <li><a href="qn_History.php">History</a></li>
                  <li><a href="qn_Math.php">Mathematics</a></li>
                  <li><a href="#">Contact Us</a></li> <!--This contact us page is stated here just for show. If we have time we can create a simple form that doesn't work-->
                </ul>
                </nav>
        </header>
        
        <!-- This is where the main content for your webpages are going to be-->
        <div class ="quiz_box">
            <h2>History Questions - Answer Qn 1 - 3</h2>
            <div class="std_id">
                <?php
                    //$student_ID = $_GET['studentNum'];
                    //echo "<h3>Student No: $student_ID </h3>"; 
                ?>
            </div>
            <div class="history_qn">
                <form action="qn_History.php" method="POST">
<!------------------------------------History - Question 1 ------------------------------------------------------------->
                    <div class="qn">
                       <?php 
                            /*1st Trial at Printing Question and Radio Button*/
                            //$qn_counter = 1;
                            /*Printing out each Question from the Array*/
                            //foreach($qns_3 as $qns_No => $value){
                                //echo $qn_counter,". ",$value['qns'],"<br>";
                                /*Printing Out Radio Buttons of Options8*/
                                /*foreach($value['ops'] as $options){
                                    echo '<input type="radio" name= $qns_3 = $options>',$options,"<br>";
                                }
                                $qn_counter++;
                            }*/
                        ?>
                        <p>1. <?php echo $question1 ?><p></p>
                        <!--Option 1 -->
                        <input type ="radio" id ="q1o1" name = "qn1" value ="<?php echo $q1option1?>"/>
                        <label for ="q1o1"><?php echo $q1option1 ?></label><br>

                        <!--Option 2 -->
                        <input type ="radio" id ="q1o2" name = "qn1" value ="<?php echo $q1option2?>"/>
                        <label for ="q1o2"><?php echo $q1option2 ?></label><br>

                        <!--Option 3 -->
                        <input type ="radio" id ="q1o3" name = "qn1" value ="<?php echo $q1option3?>"/>
                        <label for ="q1o3"><?php echo $q1option3 ?></label><br>

                        <!-- Qn3 Action Handler-->
                        <div class = "action_handler">
                            <?php
                                $counter = 0;
                                if(isset($_POST['qn1'])){
                                    $ans1 = $_POST['qn1'];
                                    var_dump($ans1);
                                }
                                else{
                                    $ans1 = NULL;
                                }

                                if($ans1 != NULL){
                                    if($ans1 != $q1ans){
                                        echo "$ans1 is incorrect";

                                    }
                                    else{
                                        echo "$ans1 is correct";
                                        $counter += 1;                                        
                                    }
                                }
                                else{
                                    echo "Select an answer for Qn.1 <br>";
                                }
                            ?>
                        </div>
                    </div>
                    <br>

<!------------------------------------History - Question 2 ------------------------------------------------------------->
                    <div class="qn">
                        <p>2. <?php echo $question2 ?></p>
                        <!--Option 1 -->
                        <input type ="radio" id ="q2o1" name = "qn2" value ="<?php echo $q2option1?>"/>
                        <label for ="q2o1"><?php echo $q2option1 ?></label><br>

                        <!--Option 2 -->
                        <input type ="radio" id ="q2o2" name = "qn2" value ="<?php echo $q2option2?>"/>
                        <label for ="q2o2"><?php echo $q2option2 ?></label><br>

                        <!--Option 3 -->
                        <input type ="radio" id ="q2o3" name = "qn2" value ="<?php echo $q2option3?>"/>
                        <label for ="q2o3"><?php echo $q2option3 ?></label><br>
                        <div class="action_handler">
                            <?php
                                if(isset($_POST['qn2'])){
                                    $ans2 = $_POST['qn2'];
                                    var_dump($ans2);
                                }
                                else{
                                    $ans2 = NULL;
                                }
                            
                                if($ans2 != NULL){
                                    if($ans2 != $q2ans){
                                        echo "$ans2 is incorrect";
                                    }
                                    else{
                                        echo "$ans2 is correct";
                                        $counter += 1;
                                    }
                                }
                                else{
                                    echo "Select an answer for Qn.2 <br>";
                                }
                            ?>
                        </div>
                    </div>
                    <br>

<!------------------------------------History - Question 3 ------------------------------------------------------------->
                    <div class="qn">
                    <p>3. <?php echo $question3 ?></p>
                        <!--Option 1 -->
                        <input type ="radio" id ="q3o1" name = "qn3" value ="<?php echo $q3option1?>"/>
                        <label for ="q3o1"><?php echo $q3option1 ?></label><br>

                        <!--Option 2 -->
                        <input type ="radio" id ="q3o2" name = "qn3" value ="<?php echo $q3option2?>"/>
                        <label for ="q3o2"><?php echo $q3option2 ?></label><br>

                        <!--Option 3 -->
                        <input type ="radio" id ="q3o3" name = "qn3" value ="<?php echo$q3option3?>"/>
                        <label for ="q3o3"><?php echo $q3option3 ?></label><br>
                        <div class="action_handler">
                        <!-- Qn3 Action Handler-->
                            <?php
                                if(isset($_POST['qn3'])){
                                    $ans3 = $_POST['qn3'];
                                    var_dump($ans3);
                                }
                                else{
                                    $ans3 = NULL;
                                }
                            
                                if($ans3 != NULL){
                                    if($ans3 != $q3ans){
                                        echo "$ans3 is incorrect";
                                    }
                                    else{
                                        echo "$ans3 is correct";
                                        $counter += 1;
                                    }
                                }
                                else{
                                    echo "Select an answer for Qn.3 <br>";
                                }
                            ?>
                        </div>
                    </div>
                    <!--End of History Quiz -->
                    <br>
                        <input type="submit" name="submit" value="Submit Quiz" class ="btn"/>
                        <a href="resultpage.php" class="result-btn">View results</a>
                    </div>
                <div class ="results">
                    <?php
                        echo "<h3>Your score for this History Quiz is $counter / 3</h3>";
                    ?>
                </div>
                </form>
            </div>

How to protect a direct download link in a Laravel API

I’m new to Laravel and I’m trying to protect some file downloads trough Laravel.

All I’ve read about it is about sending files as “blob” but this solution has issues when I download Blob in my React App: some files stop the download before the entire file is received.

The methode I used

return response()->download($file, 'Test File', $headers, 'inline');

Thanks for the help

How can I merge just parts of a PHP array?

I have a system that should forward incomming SMS to email. (Currently the script just forwards the file as is… Not very elegant.)
This system deals with a text file with multiple lines. I read it with file() directly into an array. The top few lines have a format as below, and I want to pick some parts out and format them into the email. The message is at the bottom of this text file, and may be over several line including blank ones.

How do I merge just the last few parts (message lines) of the array not knowing the number of lines that it has in total? I think I know which line to start at…

From: 479064xxxx
From_TOA: 91 international, ISDN/telephone 
From_SMSC: 479200xxxx
Sent: 22-02-09 13:34:05
Received: 22-02-09 12:34:29
Subject: GSM1
Modem: GSM1
IMSI: 2420266xxxxxxxx
IMEI: 8643940xxxxxxxx
Report: no
Alphabet: ISO
Length: 5

Actual message comes here!

How to check if at last post and navigate to first post

I have page arrows (Previous and Next ) on every single post however when I reach the last post I want to still keep the Next button which will link to the first post and vice versa if I’m on the first post I want to keep the previous button which would link to last post.

This is my .twig file which currently simply navigates to next or previous post if there is one.

<div class="post-prev">
    {% if post.prev %}
          <a href="{{ post.prev.link }}">Previous</a>
    {% endif %}
</div>
<div class="post-next">
    {% if post.next %}
          <a href="{{ post.next.link }}">Next</a>
    {% endif %}
</div>

and my PHP file which orders posts by date.

$context = Timber::get_context();
$context[ "main_menu" ] = new TimberMenu('main');

$context['page'] = new TimberPost();

$args = array(
    // Get post type project
    'post_type' => 'post',
    // Get all posts
    'posts_per_page' => -1,
    // Order by post date
    'orderby' => array(
        'date' => 'DESC'
    )
);

Dynamic Loading Interface Until The Data Is Processed

I am writing a php program that takes URL as input from the users and finds out the dead links from that webpage of the URL. Sometimes, if the webpage is too big then my execution speed of the program takes some more time. So how can I make a dynamic interface like loading (until the data program is fully executed)?

Symfony 5: 500 errors are not catched in prod environment

I have a strange problem in a symfony 5.3.10 app and i can’t wrap my head around it.

If i trigger a 500 error, like so:

/**
 * @Route("/", name="pvr_index", methods={"GET"})
 */
public function index(): Response
{
    echo $a;

Where $a is not defined, in dev environment i get a nice error page.

I’d expect that in prod i would get a not so nice error page that just tells me that i have a 500 error. And this would happen correctly until some time ago, when something changed, but i don’t know what.

Now instead i get no error, not even in the symfony server console, and the script execution would keep on going like nothing happened.

What i tried:

Adding the supposed exception inside a try/catch:

try {
        echo $a;
    }
    catch (Exception $e)
    {
        dump($e);
        die();
    }

Nothing happens, the catch isn’t triggered.


Creating an exception listener:

In services.yaml i have:

exception_listener:
    class: AppEventExceptionListener
    tags:
        - { name: kernel.event_listener, event: kernel.exception }

And in ExceptionListener.php i have:

class ExceptionListener
{
    public function __construct(Environment $engine) {
        $this->engine = $engine;
    }
    public function onKernelException(ExceptionEvent $event)
    {
        dd($event->getThrowable()->getMessage());
    }
}

Still nothing happens, the listener isn’t triggered.

Everything works as expected in dev environment, the problem presents itself only in prod.

Looking at a phpinfo(); page i see that the error reporting is enabled, so i think that the problem lies in the symfony configuration.

I’m using php 7.4 and have no real access to the php.ini file