I’m facing a persistent and unusual issue with a multi-role, multi-tenant Laravel application and I’m hoping someone can shed some light on what might be happening.
The Goal:I have a multi-tenant application where each tenant is a hotel. The application has four main user roles:
1.Admin (Super Admin)
2.Hotel Manager (Manages a specific hotel/tenant)
3.Branch Manager (Manages a branch under a hotel)
4.Customer (Belongs to a specific hotel/tenant)
The Problem:Logins for Admin, Hotel Manager, and Branch Manager work perfectly. However, when a Customer tries to log in, they are stuck in a redirect loop back to the login page.The laravel.log file clearly shows that the customer authentication is successful, a session is created, and a redirect to /customer/dashboard is initiated. But the user never reaches the dashboard and is immediately sent back to the login page.
My Environment:
•PHP: 8.2.12
•Framework: Laravel (latest version)
•Local Server: XAMPP, served with php artisan serve –port=8001
•Authentication: Custom login logic (not using standard Laravel Fortify/Jetstream).
What I’ve Tried (The Debugging Journey):This is where it gets strange. The core of the problem seems to be that my application is not loading the updated versions of certain PHP files, specifically my middleware.
1.Initial Diagnosis: I suspected an issue in my CustomerAuth middleware or the CustomerDashboardController. I added detailed Log::info() statements to CustomerAuth.php to trace the session state.
2.The Core Issue – Files Not Updating: The detailed logs I added never appear in laravel.log. This proves that despite my changes, Laravel is still running an old, cached, or otherwise outdated version of CustomerAuth.php.
3.Troubleshooting Steps Taken (Repeatedly):
•Cleared all caches: I have run php artisan optimize:clear, config:clear, cache:clear, view:clear, and route:clear countless times.
•Restarted the server: I have stopped (Ctrl+C) and restarted the php artisan serve process after every change.
•Cleared browser cache: Performed a hard refresh and cleared all site data from the browser.
•Checked file paths: The file path is correct: C:xampphtdocsmyprojectappHttpMiddlewareCustomerAuth.php.
•Composer Dump-Autoload: I ran composer dump-autoload successfully.
4.Isolating the Session: To confirm that the session itself was working, I modified my LoginController to redirect customers to a temporary, unprotected route (/customer/test-session). This worked! The test page loaded and successfully displayed the customer’s session data.
This proves:
•The customer session is being created and persists correctly after login.
•The problem is triggered when the request hits the customer.auth middleware or the associated controller/route.
The Block:Even after proving the session works, and after restoring the original LoginController logic, I am still unable to get my application to execute the updated CustomerAuth.php file containing the debug logs. The laravel.log remains clean of my new log statements, and the customer is still stuck in the login loop.My Question:Given that I’ve cleared all standard caches and restarted the server, what could possibly be preventing Laravel (specifically when running under php artisan serve on Windows/XAMPP) from loading the latest version of a PHP file? Is there a deeper caching mechanism (like Opcache, though I haven’t configured it explicitly) or a known issue with this kind of setup that I’m missing?I’m at a loss for why this one specific middleware file refuses to update in the running application.
Any help or new ideas for debugging this environment-specific issue would be greatly appreciated.
Thank you
Category: PHP
Category Added in a WPeMatico Campaign
Laragon + Visual Studio Php Server & Live Server + Live Server Web Extension Not Auto-Reloading Together
I’m attempting to set up a development environment where I can edit PHP files stored under C:laragonwww, and have the browser automatically reload when I save changes. I am using Laragon to run the PHP and database servers, and I want to use the Live Server extension in Visual Studio Code to facilitate live reloading.
What works:
- Static files in the project directory load correctly at
http://127.0.0.1:5500/with Live Server. - Laragon is running smoothly, providing database access, and the PHP server is accessible at
http://localhost:3000/laragon/www/. - My virtual hosts are active, with the document root set to
C:laragonwww.
What doesn’t work:
- When I make changes to PHP files, the Live Server extension does not automatically reload the page.
- Reloading only works for static files, not PHP pages served by Laragon.
Setup details:
- Web server: Laragon PHP server at
http://localhost:3000/laragon/www/ - Static files: load at
http://127.0.0.1:5500/with Live Server - Ports: Apache at 8080 (with SSL at 443), PHP at 3000
- Files are saved within
C:laragonwww
Attempts made:
- Accessed PHP pages via
localhost:8080,localhost:3000, and192.168.131.1:8080/3000 - Tried various URL paths and directory configurations.
- Checked configurations and tried to configure Live Server to proxy or watch PHP files (though I understand Live Server is primarily for static content).
Questions:
- Has anyone managed to get Live Server or similar tools to automatically reload PHP pages served through Laragon?
- Are there specific configurations, extensions, or alternative tools recommended for live reloading PHP files?
- Are there known limitations or best practices for PHP development with live reload integrations?
Thanks in advance for any guidance or experiences. I appreciate your help!
Sub-grouping a group by month and year
Doctrine ODM allows to group a set of matched documents: https://www.doctrine-project.org/projects/doctrine-mongodb-odm/en/2.9/reference/aggregation-stage-reference.html#group
Consider documents having properties “type” and “date”. I’d like to get data grouped by type and sub-grouped by month and year.
So far, I was able to group like the following:
array(2) {
["_id"]=>
array(1) {
["type"]=>
string(6) "A"
}
["byMonth"]=>
array(5) {
[0]=>
array(2) {
["month"]=>
int(7)
["year"]=>
int(2025)
}
[1]=>
array(2) {
["month"]=>
int(7)
["year"]=>
int(2025)
}
[2]=>
array(2) {
["month"]=>
int(3)
["year"]=>
int(2025)
}
[3]=>
array(2) {
["month"]=>
int(3)
["year"]=>
int(2025)
}
[4]=>
array(2) {
["month"]=>
int(1)
["year"]=>
int(2025)
}
}
}
array(2) {
["_id"]=>
array(1) {
["type"]=>
string(6) "B"
}
["byMonth"]=>
array(1) {
[0]=>
array(2) {
["month"]=>
int(2)
["year"]=>
int(2025)
}
}
}
Here is the code used:
$aggBuilder = $dm->createAggregationBuilder(Example::class);
$aggBuilder->match()
->field('date')
->gte($from)
->lte($to)
;
$aggBuilder->group()
->field('id')
->expression(
$aggBuilder->expr()
->field('type')
->expression('$type')
)
->field('byMonth')
->push(
$aggBuilder->expr()
->field('month')
->month('$date')
->field('year')
->year('$date')
)
;
But as you can see, data is not aggregated for type A on months 3 and 7.
So, instead of just pushing the data (hence not grouped by month), how is it possible to aggregate the nested data by month?
alternative for this code not using eval or for newer PHP versions [duplicate]
<?php
$d=10;
$i=10;
$s=10;
$fc = `$d==$i && $i==$s`;
$f = '$d + 100';
$code = 'if ((' . $fc . ') == TRUE) { return "' . $f . '";}';
$ntotal = eval($code);
?>
Any alternative for this simple code NOT using eval or for newer PHP versions.
Problem creating a query in MySQL via PHP [closed]
I´m trying to connect with MySQL and create a query, but I’m unable and I don’t know why. Hope you can help.
This is my code
$host="myhost";
$username="myusername";
$password= "mypw";
$db="mydB";
$conn = mysqli_connect($host,$username,$password,$database);
if (!$conn) {
die("Conection failed: " . mysqli_connect_error());
}
else
{
echo "Connected successfully";
}
$sql="SELECT * FROM Books ORDER BY Downloads DESC LIMIT 50";
$result = mysqli_query($conn, $sql);
if (!$result) {
die("Query error: " . mysqli_error($conn));
}
if (mysqli_num_rows($result) > 0)
{
echo "<table id='menu'><tr><td>ID</td><td>Name Book</td><td>Downloads</td></tr>";
while ($row = mysqli_fetch_assoc($result))
{
$U = $row['Link'];
$Title = $row['Title'];
$plat= $row['Genre'];
echo "<tr><td><font color='black'><p align='left'><ul type='square'><li><a href='$U' target='blank' title='Download $Titulo $plat Book'>".$Title."</a>(".$plat.")</li></ul></font>";
}
echo "</td></tr></table>";
}
else
{
die ("cannot connect");
}
mysqli_close($conn);
?>
Thank you in advance
Codeigniter 4 AbstractRenderer::SORT_FULL;
I have detected the following unusual problem, with codeigniter4.
Install.
PHP: 8.4.10 — CodeIgniter: 4.6.1 -- Environment: development
Error.
Undefined constant KintRendererAbstractRenderer::SORT_FULL
My composer file.
{
"name": "codeigniter4/appstarter",
"description": "CodeIgniter4 starter app",
"license": "MIT",
"type": "project",
"homepage": "https://codeigniter.com",
"support": {
"forum": "https://forum.codeigniter.com/",
"source": "https://github.com/codeigniter4/CodeIgniter4",
"slack": "https://codeigniterchat.slack.com"
},
"require": {
"php": "^7.4 || ^8.0",
"codeigniter4/framework": "^4.0",
"tatter/assets": "dev-master",
"twbs/bootstrap": "v5.3.7"
},
"require-dev": {
"fakerphp/faker": "^1.9",
"kint-php/kint": "^6.0",
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^9.1"
},
"autoload": {
"exclude-from-classmap": [
"**/Database/Migrations/**"
]
},
"autoload-dev": {
"psr-4": {
"Tests\Support\": "tests/_support"
}
},
"config": {
"optimize-autoloader": true,
"preferred-install": "dist",
"sort-packages": true
},
"scripts": {
"test": "phpunit"
}
}
It’s a normal zero installation dicodeigniter 4 but instead it gives me this error.
Everything is up to date and should not be there. How can I verify that kint library loads.
I tried putting .env in production and everything works.
When it loads kint in development it gives me this error.
Does anyone know what it can be?
Why when using Symfony UX and Forms I get INVALID CSRF TOKEN?
I have a question regarding Symfony UX Live Components and forms.
Context:
Imagine you have a Parent Component and a nested Child Component. Both are Live Components and both include Symfony FORMS (FormBuilder). However, the submit button for the child’s form is located in the Parent Component, and I use a LiveComponent emit to dispatch an event that the child’s save method listens for.
Although the event arrives correctly, I get an Invalid CSRF-TOKEN error coming from the child component.
While investigating, I discovered that Turbo UX uses the csrf_protection_controller.js Stimulus controller to generate a CSRF token. What does this imply? Must I disable Symfony’s default CSRF token handling for forms?
In my csrf.yaml, I currently have:
# Enable stateless CSRF protection for forms and logins/logouts
framework:
form:
csrf_protection:
token_id: submit
csrf_protection:
check_header: true
stateless_token_ids:
# - submit
- authenticate
- logout
When I disable the submit entry under stateless_token_ids, the form no longer raises a CSRF error. If I inspect the Symfony Profiler (under the child’s save request → Forms), it shows :
Screenshot of Symfony Profiler
Does the CSRF token still exist, and should I therefore leave submit disabled in csrf.yaml?
Why aren’t there clear references or documentation explaining that Turbo UX uses its own controller for token generation and CSRF handling?
Thank you very much!
Issue with browsershot generating pdf only in prod
I am trying to use spatie laravel-pdf which uses browsershot under the hood to generate a pdf. I get the bellow error only on the production server when trying to generate the pdf which seems to not include any useful information regarding the problem. The index.html file does contain the contents I’m expecting. Confirmed nodejs folder in system path env variable.
The command “node C:inetpubwwwrootmyprojectvendorspatiebrowsershotsrc/../bin/browser.cjs “{“”url””:””file://C:WindowsTEMP607378296-0455840001752189861index.html””,””action””:””pdf””,””options””:{“”args””:[],””viewport””:{“”width””:800,””height””:600},””displayHeaderFooter””:false,””margin””:{“”top””:””0.25in””,””right””:””0.25in””,””bottom””:””0.25in””,””left””:””0.25in””},””format””:””letter””,””landscape””:true,””printBackground””:true}}”” failed. Exit Code: 1(General error) Working directory: C:inetpubwwwrootmyprojectpublic Output: ================ Error Output: ================
I have the following controller method which is used to generate the pdf.
<?php
namespace AppHttpControllers;
use SpatieLaravelPdfEnumsFormat;
use SpatieLaravelPdfEnumsUnit;
use SpatieLaravelPdfFacadesPdf;
class ExportController extends Controller
{
public function pdf() {
$pdf = Pdf::view('table-pdf');
return $pdf->format(Format::Letter)
->margins(0.25, 0.25, 0.25, 0.25, Unit::Inch)
->landscape()
->name("myfile.pdf");
}
}
I’ve tried using withBrowserShot method and called setNodeBinary() and noSandbox() methods, neither of which made any difference. Any ideas as to where to start? I’ve tried uninstalling and reinstalling puppeteer which did not help.
Opcache question moving from php 8.0 to 8.3
On Almalinux 8 PHP 8.0 and 8.3 are installed.
The default php release is 8.0 (php -v = 8.0) and all running websites use php 8.0 in FPM mode.
I want to move all to php 8.3
Sites are wordpress, so I can easily change php version there, but my question is about opcache (installed on both release). I check the opcache status using opcache-gui (https://github.com/amnuts/opcache-gui) that currently shows that it is running for php 8.0
I began to move one website to 8.3. Site is working but opcache-gui doesn’t show the cached files from this site. Is it because the server default php is 8.0, so opcache-gui only shows the cached files of sites under php 8.0? So, if I set the server default php to 8.3, will opcache-gui automatically monitor the php 8.3 opcache system, or are there additional setups to do?
Thank you!
How to add custom content or static HTML below dynamic coupon listings in a PHP-based store page? [closed]
I purchased a PHP-based coupon theme for my site, and I’m trying to customize the store pages. Here’s an example page: https://flashvoucher.com/store/a2-hosting
Currently, the page shows the list of coupons dynamically fetched from the database. However, there’s no option in the theme settings to add static content (like a small paragraph or HTML block) below the coupon list. I want to add some SEO-friendly text, maybe 200–300 words about the store, right after the coupons end.
The theme uses PHP templates and seems to be built using procedural PHP (not any modern frameworks). I can edit the template files directly.
Question:
What would be the best way to inject custom content (manually or via admin, if possible) just below the dynamic content block? Should I:
Modify the template file and hardcode the HTML block?
Use output buffering or hooks (if available)?
Append content via controller logic if it exists?
Any advice or code example would be appreciated.
Latest Telescope does not work if Laravel is in a subfolder & Quick Fix Also Not Working
Telescope Version : 5.10
Laravel Version : 10.48.29
PHP Version : 8.3.11
Issue
Laravel runs in a subfolder. This means only urls starting with /foo/ get routed to Laravel’s index.php. Other urls like /telescope/ are out of laravels control. Laravel’s router is smart enough to check that it is in a subforlder and ignores /foo/ in the url when matching routes. As a result the route “/telescope” automatically get converted to “example.com/foo/telescope” when printing routes with route() and the router maps /foo/telescope to telescopes controller. Telescope is not so smart. It takes the path from the config “path” => “telescope” and creates urls starting with “/telescope”. If i change it to “path” => “foo/telescope” Laravel’s router interprets them as “/foo/foo/telescope”. This results in Telescope still being incorrect because its javascript tries to send api requests to “/foo/telescope/telescope-api” but “/foo/foo/telescope/telescope” would be correct.
Quick Fix – Not Working
I’ve tried adding this fix in the bottom part also in header in both cases the path and basePath is going back to /telescope.
@php
$url = parse_url(config('app.url'));
$basePath = isset($url['path']) ? $url['path'] . '/telescope' : 'telescope';
$path = isset($url['path']) ? ltrim($url['path'], '/') . '/telescope' : 'telescope';
$vars = LaravelTelescopeTelescope::scriptVariables();
$vars['basePath'] = $basePath;
$vars['path'] = $path;
@endphp
<script>
window.Telescope = @json($vars);
console.log(window.Telescope.basePath);
console.log(window.Telescope.path);
</script>
How do I insert data from a database into a form using a radio input? [closed]
I have searched for 2 days! I cannot find the answer. I am not sure I am wording this question correctly. What I am doing, I have rental units, and tenants. I have a form, I want to insert data from rental units database into the tenant info database, in a radio format. EXAMPLE, I have a new tenant moving in, I need to select the rental unit they are moving into. To see what I have, go to 3602online.com click Log In in the upper right corner. Look at the bottom of the form and register, I can delete any abusive users. Now, once a member, and logged in, go to Manage Rentals tab, and on the left, select Add Tenant. Now, this is the form I am having issues with. The radio buttons show, but the data I tried to retrieve from the rental unit DB does not show! I am not great at programming, but also, not stupid! Thank you if you can help me!
<!-- Rental Unit input -->
Rental Unit:
<!-- FETCHING DATA FROM EACH ROW OF EVERY COLUMN -->
<!-- PHP CODE TO FETCH DATA FROM ROWS -->
<?php
// LOOP TILL END OF DATA
while($rows = $result->fetch_assoc()) {
?>
<br/><br/>
<input name="rental_unit" <?php echo $rows['address'];?> required type="radio" />
<?php
}
?>
How to transfer fields to a database where one field is foreign?
I can’t add fields to the profile, user_id seems to work, the values are correct, but it doesn’t add to the field, but if I change it manually in mysql, it changes the value without errors, what should I do?
It turns out that my question is that when a user registers, in addition to the user, a profile is created that is linked by user_id, but I can’t do it no matter how much I try
I have a database, here are its migrations(profile):
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 10,
'unsigned' => true,
'auto_increment' => true,
],
'firstname' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'lastname' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'email' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'phone' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => true,
],
'description' => [
'type' => 'TEXT',
'constraint' => '128',
'null' => true,
],
'date_birth' => [
'type' => 'DATE',
'null' => true,
],
'avatar' => [
'type' => 'TEXT',
'null' => true,
],
'user_id' => [
'type' => 'int',
'constraint' => 11,
'unsigned' => true,
'null' => false,
],
]);
$this->forge->addForeignKey('user_id', 'user', 'id', '', 'CASCADE');
$this->forge->addPrimaryKey('id')->addUniqueKey('user_id');;
$this->forge->createTable('profile');
}
public function down()
{
$this->forge->dropTable('profile');
}
user migration:
public function up()
{
$this->forge->addField([
'id' => [
'type' => 'INT',
'constraint' => 10,
'unsigned' => true,
'auto_increment' => true,
],
'name' => [
'type' => 'VARCHAR',
'constraint' => '128',
'null' => false,
],
'password_hash' => [
'type' => 'VARCHAR',
'constraint' => '255',
'null' => false,
]
]);
$this->forge->addPrimaryKey('id')->addUniqueKey('name');
$this->forge->createTable('user', true);
}
public function down()
{
$this->forge->dropTable('user');
}
controller registration (the task when creating a user is to create a separate profile):
public function create_account()
{
$user = $this->request->getPost();
$avatar = $user['avatar'];
if ($user) {
if ($this->model->insert($user)) {
$user_id = $this->request->getPost('name');
$login = $this->model->where('name', $user_id)->first();
$session = session();
$session->set('user_id', $login->id);
$session->set('user_name', $login->name);
if (session()->has('user_id') && $this->profile->insert(['firstname' => 'ivan', 'avatar' => $avatar, 'user_id' => 18])) {
return redirect()->to('/home')->with('success', ['Вы успешно авторизовались']);
}
} else {
return redirect()->back()->with('errors', $this->model->errors())->with('warning', 'Invalid data')->withInput();
}
}
}
Run reactJS or VueJS application in webmin security tools [closed]
I have a question.
If you use Webmin or Virtualmin on Ubuntu, I use at work for website and domain security on Digital Ocean hosting. I have a question.
We want to develop a company profile website using React.JS or Vue.JS (Node.JS, npm). Can it be installed and run on a VPS server with another port?
Can it be implemented by following the server settings? Is there a tutorial? Thank you in advance for your insight.
If possible, how do you set it on this tools? If not, it will run individually.
Codeigniter 4 php spark publish command failed to publish files
After Upgrading to the latest Codeigniter 4 version, when I am trying to run the command
php spark publish
Then I am getting an error failed to publish to and more specifically for the reason:
fails the following restriction for "/path/to/my/project/public/": #.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)
Details of the error:
CodeIgniter v4.6.1 Command Line Tool - Server Time: 2025-07-09 03:30:54 UTC+00:00
"AppPublishersGroceryCrudPublisher" failed to publish to "/path/to/my/project/public/".
/path/to/my/project/vendor/grocery-crud/enterprise/public/vendor/grocery-crud/static/media/index.f6d03137e8c9dd0de04c.cjs
"/path/to/my/project/vendor/grocery-crud/enterprise/public/vendor/grocery-crud/static/media/index.f6d03137e8c9dd0de04c.cjs" fails the following restriction for "/path/to/my/project/public/": #.(s?css|js|map|html?|xml|json|webmanifest|ttf|eot|woff2?|gif|jpe?g|tiff?|png|webp|bmp|ico|svg)$#i
What is the best way to fix the above? Consider that removing the .cjs files is an option but then I am also getting same errors for .DS_Store files. Is there any option in Codeigniter 4 to just skip copying those files instead of throwing an error?