Laravel 11 Events Firing Multiple Times in Production (Nginx, Azure App Services, PHP 8.3)

I’m encountering an issue where Laravel events are firing multiple times, but only in the production environment.

Environment:

  • Laravel: 11.x
  • PHP: 8.3
  • Web Server: Nginx
  • Hosting: Azure App Services
  • Setup:
    • One App Service runs the main Laravel application
    • A separate App Service handles scheduled tasks (cron)

We are dispatching Laravel events like this:

event(new ApplicationStatusChanged($application));

In production, these events trigger multiple times for a single operation. For example, a single POST request causes the event listener to run 2 times.

Check on direct GET request for Test and getting the same.

This does not happen in the local development environment.

We’re trying to understand:

  • Could this be due to Azure App Service architecture, deployment replication, or Nginx misconfiguration?
    • Why might synchronous Laravel events fire multiple times in a production setup like this?
  • Are there known quirks or debugging tips for this kind of behavior in Laravel 11/PHP 8.3?

We’ve ruled out:

  • Not using ShouldQueue on either the event or the listener — they are all synchronous.
  • Listeners are not making changes that could retrigger the event.
  • Confirmed it’s not job retries or queue-related (we’re not queuing).
  • No duplicate requests are hitting the endpoint.
  • Cache cleared completely (config, route, event, etc.).
  • Stopped the cron App Service entirely — issue still persisted

File upload error – unable to create a temporary file. PHP/HERD/LARAVEL

I’m using the following stack:

  • Laravel Herd
  • Laravel v12.0
  • PHP v8.2.28
  • maatwebsite/excel v3.1 (Laravel Excel)
  • Postman
  • Windows 10 OS

What I’m Trying to Do

I want to send a POST request containing an Excel file (.xlsx). This file should then be processed using the maatwebsite/excel package to create new records based on its contents.

The Problem

When I send the POST request using Postman with form-data containing the Excel file, I get this error:

Warning: File upload error - unable to create a temporary file in Unknown on line 0

Here’s a screenshot for more details:
error screnshoot

Here’s my code

routesapi.php

Route::controller(AlumniController::class)->group(function () {
    ...
    Route::post('/alumnis/import', 'importExcel'); // this is the endpoint for import excel
});

appHttpControllersAlumniController.php

use IlluminateHttpRequest;
use AppImportsAlumnisImport;
use MaatwebsiteExcelFacadesExcel;

class AlumniController extends Controller
{
    ...

    public function importExcel()
    {
        try {
            Excel::import(new AlumnisImport, request()->file('alumni_excel'));
        } catch (Throwable $th) {
            dd($th);
        }
    }
}
appImportsAlumnisImport.php

use AppModelsAlumni;
use AppModelsJurusan;
use MaatwebsiteExcelConcernsToModel;

class AlumnisImport implements ToModel
{
    /**
     * @param array $row
     *
     * @return IlluminateDatabaseEloquentModel|null
     */
    public function model(array $row)
    {
        $jurusan = Jurusan::firstOrCreate(
            ['nama' => $row['nama_jurusan']],
            ['nama' => $row['nama_jurusan']]
        );

        return new Alumni([
            'nama' => $row['nama'],
            'tgl_lahir' => $row['tgl_lahir'],
            'tahun_mulai' => $row['tahun_mulai'],
            'tahun_lulus' => $row['tahun_lulus'],
            'no_tlp' => $row['no_tlp'],
            'email' => $row['email'],
            'password' => isset($row['password']) ? $row['password'] : null,
            'alamat' => $row['alamat'],
            'tempat_kerja' => $row['tempat_kerja'] ?? null,
            'jabatan_kerja' => $row['jabatan_kerja'] ?? null,
            'tempat_kuliah' => $row['tempat_kuliah'] ?? null,
            'prodi_kuliah' => $row['prodi_kuliah'] ?? null,
            'kesesuaian_kerja' => isset($row['kesesuaian_kerja']) ? filter_var($row['kesesuaian_kerja'], FILTER_VALIDATE_BOOLEAN) : null,
            'kesesuaian_kuliah' => isset($row['kesesuaian_kuliah']) ? filter_var($row['kesesuaian_kuliah'], FILTER_VALIDATE_BOOLEAN) : null,
            'photo' => $row['photo'] ?? null,
            'jurusan_id' => $jurusan->id,
        ]);
    }
}

Need Help

Has anyone experienced this issue before? Could it be related to Laravel Herd? I’d really appreciate any help or suggestions to solve this. If you need more info, feel free to leave a comment. Thanks

Illegal mix of collations on basic SELECT query

I got the following error on a simple select query:

[21-May-2025 20:20:52 America/New_York] PHP Fatal error:  Uncaught PDOException: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (latin1_swedish_ci,IMPLIC
IT) and (utf8mb4_0900_ai_ci,COERCIBLE) for operation '=' in /home/server/public_html/api/v1/0.50/includes.php:196
Stack trace:
#0 /home/server/public_html/api/v1/0.50/includes.php(196): PDOStatement->execute(Array)
#1 /home/server/public_html/api/v1/0.50/emailVerify.html(86): dbSelect('SELECT * FROM u...', Array)
#2 {main}

Its a table that hosts user emails and verification codes. The user is sent an email and when they click on a link in the email, the link the opens the validation page and in that page it does the following query simple query:

$vCode = $_REQUEST['v'] ;       // IE:  YzFlMGM3M2M1NDIyMzhkNDUxNGFkNGF
$userEmail = $_REQUEST['e'] ;   // IE: [email protected]

$query = "select * from userEmailVerify where user_email=? and code=?" ;
$stmt = $pdo->prepare($query) ;
$result = $stmt->execute([$userEmail,$vCode]) ;

This query is performed dozens of times a day and over the 3 years this table and scripts have been in service this is the first time I have ever seen this error. I manually performed the same SELECT query using the users email and verification code that triggered this error and the query worked fine. The error happened back on the 21st and the same scripts have been processed dozens of times since that error without any further error.

I have read several threads about collation and don’t think any of what I read applies to this situation.

What could have caused this?

Call to undefined function hexToRgb() [closed]

In my script file head.blade.php I have this:

<link rel="apple-touch-icon" sizes="180x180" href="{{asset('favicon/apple-touch-icon.png')}}">
<link rel="icon" type="image/png" sizes="32x32" href="{{asset('favicon/favicon-32x32.png')}}">
<link rel="icon" type="image/png" sizes="16x16" href="{{asset('favicon/favicon-16x16.png')}}">
<link rel="manifest" href="{{asset('site.webmanifest')}}">
@vite(['resources/scss/app.scss', 'resources/js/app.js'])

<style>
    :root {
    @if(config('settings.palette'))
        @foreach(config('attr.colors.'.config('settings.palette')) as $color => $value)
            {{'--color-gray-'.$color.':'.hexToRgb('#'.$value)}};
        @endforeach
    @else
        @foreach(config('attr.colors.zinc') as $color => $value)
            {{'--color-gray-'.$color.':'.hexToRgb('#'.$value)}};
        @endforeach
    @endif
           --color-primary-500: @if(config('settings.color')){{hexToRgb(config('settings.color'))}}@else{{hexToRgb('#8b5cf6')}}@endif;
    }
</style>
{!! config('settings.custom_code') !!}
@if(config('settings.onesignal_id'))
    <script src="https://cdn.onesignal.com/sdks/OneSignalSDK.js" defer></script>
    <script>
        window.OneSignal = window.OneSignal || [];
        OneSignal.push(function () {
            OneSignal.init({
                appId: "{{env('ONESIGNAL_APP_ID')}}"
            });
        });

        OneSignal.push(function () {
            OneSignal.showNativePrompt();
        });
    </script>
@endif

And I get the error : Call to undefined function hexToRgb()
Image:

enter image description here

Can be from composer? Or what?

I tried to add a color for it but doesn’t work…

Sylius 2, Symfony 7 and PHP 8 : AbstractLoader.php:104 “Unknown named parameter $value” on clear:cache

When I run bin/console cache:clear in my Sylius 2 / Symfony 7 project, I get a fatal error during the Validator cache warming phase:

bin/console c:c
CRITICAL [php] Uncaught Error: Unknown named parameter $value
# in vendor/symfony/validator/Mapping/Loader/AbstractLoader.php line 104
SymfonyComponentValidatorMappingLoaderAbstractLoader->newConstraint()
SymfonyComponentValidatorMappingLoaderXmlFileLoader->parseConstraints()
...

It appears that the XML loader is trying to instantiate a Constraint class with a named $value argument that doesn’t exist in its constructor.

‘RequestFactory::fromGlobals() cannot be called statically’ error on upgrading Nette

I’m currently doing a major upgrade on a Nette based website. We have multiple custom DI extensions, custom ORM and use the Nittro UI framework. So the upgrade is quite involved.
Going from PHP 7.2 -> 8.4 and Nette 2.2 -> 3.2. I have been able to solve tens of errors, but not this one.

I get Non-static method NetteHttpRequestFactory::fromGlobals() cannot be called statically error whenever I try to load a page. This error (according to Tracy) seems to be coming from the following segment of the auto-generated DI container:

public function createServiceHttp__request(): NetteHttpRequest
{
    return NetteHttpRequestFactory::fromGlobals();
}

The thing is, I don’t create the service anywhere, it’s Nette’s – and I guess, that it comes from NetteBridgesHttpDIHttpExtension line 56:

$request = $builder->addDefinition($this->prefix('request'))
            ->setFactory('@NetteHttpRequestFactory::fromGlobals');

I have tried going down ->setFactory – but I can’t even find it on the Definition class. More over I probably have misconfigured my debugger as it won’t stop on breakpoints in the cached container.

How do I fix this? Can I perhaps replace the http.request service with one of my own?

Thanks in advace!

This is part of my composer.json:

    "require": {
        "php": ">=8.4",
        "ext-pdo": "*",
        "ext-pdo_firebird": "*",
        "ext-curl": "*",
        "ext-json": "*",
        "ext-libxml": "*",
        "ext-simplexml": "*",
        "nette/application": "3.2.*",
        "nette/bootstrap": "3.2.*",
        "nette/forms": "3.2.*",
        "nette/http": "3.3.*",
        "nette/security": "3.2.*",
        "nette/di": ">=3.2",
        "nette/caching": "3.3.*",
        "nette/robot-loader": ">=4",
        "tracy/tracy": ">=3",
        "nittro/nette-bridges": "*",
        "symfony/console": ">=7.3",
        "latte/latte": ">=3",
        "jahudka/porm": "^0.1.0",
        "jahudka/component-events": "*"
    }

(some of the things are linked from forked repos, not the public versions)

How to Fetch Other Posts on Scroll Without AJAX(With Fetch API) and Jquery in WordPress? [closed]

I want to fetch other posts in WordPress. I can fetch next post on scroll. But when I go to latest post, it fetches nothing. When I go to the second latest post, on scroll it fetches only first post. When I go to the third latest post, it fetches only first and second latest posts. And so on. I want to fetch all posts on scroll, one by one.

<?php
$next_post = get_next_post();
  if ($next_post) :
    $next_post_url = get_permalink($next_post->ID);
?>
    <a id="next-post-link" href="<?php echo esc_url($next_post_url); ?>" 
       style="display: none;">
    </a>
<?php endif; ?>

JavaScript

document.addEventListener("DOMContentLoaded", function()
  {
  let loading = false;

  window.addEventListener("scroll", function()
    {
    let nextPostLink = document.getElementById("next-post-link");

    if (!nextPostLink || loading) return;

    let scrollPosition = window.innerHeight + window.scrollY;
    let documentHeight = document.documentElement.scrollHeight;

    if (scrollPosition >= documentHeight - 200) 
      {
      loading = true;
      let url = nextPostLink.href;

      fetch(url)
      .then(response => response.text())
      .then(data => 
        {
        let parser  = new DOMParser();
        let doc     = parser.parseFromString(data, "text/html");
        let newPost = doc.querySelector("#post-container .post");

        if (newPost) 
          {
          document.getElementById("post-container").appendChild(newPost);

          let newNextPostLink = doc.querySelector("#next-post-link");
          if (newNextPostLink) 
            {
            nextPostLink.href = newNextPostLink.href;
            } 
          else 
            {
            nextPostLink.remove(); // No more posts
            }

          // Update URL without reloading
          history.pushState(null, "", url);
          }

        loading = false;
        })
      .catch(error =>
        {
        console.error("Error fetching next post:", error);
        loading = false;
        });
      }
    });
  });

webserver is not working on systemd as a service [closed]

I have a php project and server , when i ran it through terminal by hitting
php -S 127.0.0.1:8000 it works fine but when i add it to systemd as a service , it guves me the following error :

May 30 15:45:32 srv714079 php[1309201]: [Fri May 30 15:45:32 2025] 127.0.0.1:45940 [500]: GET /scp/login.php - Uncaught Error: Call to undefined function osTicketMail_S() in /var/www/html/osticket/include/class.mailer.php:635 
May 30 15:45:32 srv714079 php[1309201]: Stack trace: May 30 15:45:32 srv714079 php[1309201]: #0 /var/www/html/osticket/include/class.mailer.php(673): osTicketMailMailer->send() 
May 30 15:45:32 srv714079 php[1309201]: #1 /var/www/html/osticket/bootstrap.php(342): osTicketMailMailer::sendmail() 
May 30 15:45:32 srv714079 php[1309201]: #2 /var/www/html/osticket/bootstrap.php(228): Bootstrap::croak() 
May 30 15:45:32 srv714079 php[1309201]: #3 /var/www/html/osticket/main.inc.php(28): Bootstrap::connect() 
May 30 15:45:32 srv714079 php[1309201]: #4 /var/www/html/osticket/scp/login.php(16): require_once('...') 
May 30 15:45:32 srv714079 php[1309201]: #5 {main} 
May 30 15:45:32 srv714079 php[1309201]:   thrown in /var/www/html/osticket/include/class.mailer.php on line 635 
May 30 15:45:32 srv714079 php[1309201]: [Fri May 30 15:45:32 2025] 127.0.0.1:45940 Closing

here is my service file

[Unit]
Description=OS Ticket  Web Server
After=network.target
[Service]
Type=simple
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Environment="LANG=en_US.UTF-8"
Environment="LC_ALL=en_US.UTF-8"
# Replace with your PHP files directory path
WorkingDirectory=/var/www/html/osticket
ExecStart=php -S 127.0.0.1:8000
#ExecStart=/usr/bin/php -S 127.0.0.1:8080 -t /var/www/html/osticket
Restart=always
RestartSec=3
# User to run the service (recommended: non-root user)
User=www-data
Group=www-data
Environment=USER=www-data HOME=/home/www-data
# Important for PHP environment
StandardOutput=journal
StandardError=journal
[Install]
WantedBy=multi-user.target

tbh i am not sure what i am doing wrong so your help is so much appreciated

i tried to change user or play with environment variable or something like that but with no success

Error invoking PHP class which extends another

In a php page i want to use a class that extend another class, but i can’t.
I got Abb.php page like this

<?php
namespace NormalPage;
use CommonClassesAaa;
require "Aaa.php";

$xxx=new Abb();
$xxx->SayHelloB();
class Abb extends Aaa
{
    public function SayHelloB()
    {
        echo "Hello B";
    }
}

In the same directory i got the Aaa.php file liek this

<?php
namespace CommonClasses;
class Aaa
{
    public function SayHello()
    {
        echo "<html>Hello!</html>";
    }
}

When i browse Abb.php i got “Error: Class “NormalPageAbb” not found in Abb.php on line 6″.
If i modify “Abb.php” like this (Abb doesn’t extend Aaa anymore)

<?php
namespace NormalPage;
use CommonClassesAaa;
require "Aaa.php";

$xxx=new Abb();
$xxx->SayHelloB();
class Abb //extends Aaa (Abb does't extends Aaa)
{  
    public function SayHelloB()
    {        
        echo "Hello B";
    }
}

The page work correctly. Where is the mistake? I’d like to have a base class to extends in every page. I know it isn’t the best way to implement oop page in php, but i need to convert an old procedural site in a “little bit modern” style and i need to do this without say to my customer “no more implementation for a year, we must rewrite evrything”. I would like to “migrate” the site page by page.

“Why is real-time key press detection does not work in Windows PHP CLI without hitting the ‘ENTER’ key?” [duplicate]

I am trying to capture real-time keypresses in Windows CLI using PHP, but Windows buffers input, forcing me to press Enter before any key detection occurs. In Linux/macOS, I can use stty -icanon to disable input buffering, but Windows does not support this.
I have tried setting stream_set_blocking(STDIN, false) but still requires ENTER.
Capturing the keypress without ENTER works via FFI where C functions like _getch(), _kbhit() which is present in msvcrt.dll are being used.
Is there any pure PHP solution to handle real-time key detection in Windows without using FFI, PowerShell, or Node.js or has anyone tried solving this problem?

sample code does not work

<?php
    $stdin = fopen('php://stdin', 'rb+');
    stream_set_blocking($stdin, 0);
    while(1)
    {
        $keypress = fgets($stdin);
        if($keypress)
        {
            echo 'Key pressed: ' . $keypress . PHP_EOL;
        }
    }

still waits for ENTER before detecting input in Windows CLI. Any pure PHP alternative?`

PHP chrome-php/chrome timed out

I’m using Symfony’s chrome-php/chrome library to measure page load performance. Some pages of the same site load, and some do not, with an error Operation timed out after 30s. Increased the timeout to a minute and up to two, but it doesn’t help. I don’t understand what the problem is, I hope for help from people who care) Function code:

    public function checkPageMetrics(string $url, string $deviceType = 'desktop'): array
{
    if (!in_array($deviceType, ['desktop', 'mobile'])) {
        throw new InvalidArgumentException('Device type must be either "desktop" or "mobile"');
    }

    $browserFactory = new BrowserFactory('/usr/bin/google-chrome');

    $browser = $browserFactory->createBrowser([
        'headless' => true,
        'noSandbox' => true,
        'windowSize' => $deviceType === 'mobile' ? [375, 812] : [1920, 1080],
        'userAgent' => $deviceType === 'mobile'
            ? 'Mozilla/5.0 (Linux; Android 10; Pixel 3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Mobile Safari/537.36'
            : 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36',
    ]);

    try {
        $page = $browser->createPage();

        $page->addPreScript('Object.defineProperty(navigator, "webdriver", { get: () => false });');

        $page->addPreScript('
            window.performanceMetrics = {
                ttfb: 0,
                domInteractive: 0,
                loadEventEnd: 0
            };

            new PerformanceObserver((list) => {
                const entries = list.getEntries();
                if (entries.length > 0) {
                    window.performanceMetrics.ttfb = entries[0].responseStart;
                }
            }).observe({type: "navigation", buffered: true});
            
            document.addEventListener("readystatechange", () => {
                if (document.readyState === "interactive") {
                    window.performanceMetrics.domInteractive = performance.now();
                }
            });
            
            window.addEventListener("load", () => {
                window.performanceMetrics.loadEventEnd = performance.now();
            });
        ');

        $navigation = $page->navigate($url);
        $navigation->waitForNavigation(Page::LOAD, 30000);

        $metrics = $page->evaluate('window.performanceMetrics')->getReturnValue();

        return [
            'device_type' => $deviceType,
            'first_byte_ms' => round($metrics['ttfb']),
            'interactive_ms' => round($metrics['domInteractive']),
            'complete_load_ms' => round($metrics['loadEventEnd']),
            'error' => null
        ];
    } catch (Exception $e) {
        return [
            'device_type' => $deviceType,
            'first_byte_ms' => null,
            'interactive_ms' => null,
            'complete_load_ms' => null,
            'error' => $e->getMessage()
        ];
    } catch (OperationTimedOut $e) {
        return [
            'device_type' => $deviceType,
            'first_byte_ms' => null,
            'interactive_ms' => null,
            'complete_load_ms' => null,
            'error' => $e->getMessage()
        ];
    } catch (NavigationExpired $e) {
        return [
            'device_type' => $deviceType,
            'first_byte_ms' => null,
            'interactive_ms' => null,
            'complete_load_ms' => null,
            'error' => $e->getMessage()
        ];
    }
}

How to resolve a “414: Request-URI Too Long” on SiteGround shared hosting of WordPress running Nginx? There is no direct access to Nginx configs

I am managing a WordPress site that is hosted on SiteGround and is being run behind Nginx which is returning “414: Request-URI Too Long” on some long post submits.

I have seen various solutions — like this one here on Stack Overflow as well as this one — that explain that config changes have to be made to core Nginx configs like this:

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;

client_max_body_size 24M;
client_body_buffer_size 128k;

client_header_buffer_size 5120k;
large_client_header_buffers 16 5120k;

But shared hosting on SiteGround does not provide direct access to Nginx configs to make a change like that.

Is there any other way I can overcome “414: Request-URI Too Long” while running WordPress on Nginx but without mucking with core Nginx configs? Perhaps in the wp-config.php? If so, how?

empty array or square bracket in my laravel filament application

i wonder has anyone of you encounter this issue before ? i used laravel filament and the server technology – nginx. i have tried many method to get this fixed , however the square bracket still exists. i tried

php artisan route:clear
php artisan optimize:clear
php artisan config:clear
php artisan view:clear
php artisan cache:clear

filament screenshot

Linux, DirectAdmin and Rouncube password save [closed]

I need to configure my email server in such way that my employees should change their password the first time they log-in. I have configured that everything , except for that password plugin that does not want to work. I have the following the config of password plugin.

 $config['password_driver'] = 'expect'; 
 $config['password_expect_params'] = '%o %u %P';
 $config['password_expect_command'] = '/var/www/html/roundcube/passwdupdater.sh';

The problem is that I get this in roundcube log file:

 [29-May-2025 17:37:40 America/New_York] PHP Warning:  popen() has been disabled for security reasons in /var/www/html/roundcubemail-1.6.9/plugins/password/drivers/expect.php on line 53 
[29-May-2025 17:37:40 America/New_York] PHP Warning:  fwrite() expects parameter 1 to be resource, null given in /var/www/html/roundcubemail-1.6.9/plugins/password/drivers/expect.php on line 54 
[29-May-2025 17:37:40 America/New_York] PHP Warning:  fwrite() expects parameter 1 to be resource, null given in /var/www/html/roundcubemail-1.6.9/plugins/password/drivers/expect.php on line 55 [29-May-2025 17:37:40 America/New_York] PHP Warning:  fwrite() expects parameter 1 to be resource, null given in /var/www/html/roundcubemail-1.6.9/plugins/password/drivers/expect.php on line 56
 [29-May-2025 17:37:40 America/New_York] PHP Warning:  pclose() expects parameter 1 to be resource, null given in /var/www/html/roundcubemail-1.6.9/plugins/password/drivers/expect.php on line 58

I tried to enable popen in /usr/local/… /disabled_php_functions

It did not help.

Any solutions?

LCP is 2.6s even after optimizing dynamic image (22KB size)

I’m trying to improve the Largest Contentful Paint (LCP) on one of my pages. The main LCP element is an image that is loaded dynamically via PHP.

I have already compressed the image and the final size is just 22KB, but the LCP is still reported as 2.6 seconds in PageSpeed Insights.

Here is the relevant CSS:

.ArtistImageD001 {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0 20px 20px 0;
}

And here’s the image element in my PHP/HTML:

<img alt="<?php echo $artistDetail->first_name . ' ' . $artistDetail->last_name; ?>"
     src="<?php echo base_url(); ?>apppanel/assets/artistimage/<?php echo $imageUrlFinalShow; ?>"
     class="ArtistImageD001" />

Despite the small image size and optimizations, LCP is still high.

What I’ve tried so far:

  • Compressed the image to 22KB.
  • Made sure object-fit: cover doesn’t cause content shifts.
  • Verified that the image is not lazy-loaded.

Questions I have:

  1. What else can I do to improve LCP in this case?
  2. Is there any PHP or HTML-related optimization I can make since the
    image is dynamic?
  3. Should I use <link rel="preload"> or something else for the image?

LCP Image

LCP Image