Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1h ago

Missing /var/run/php-fpm.sock after reboot

Do tell, what is it that I clearly don't know?

That php-fpm.sock disappearing means this is an issue with php-fpm. That should be everything you need to know to diagnose what's wrong if you're familiar with Linux.

Answer these questions to start: do you have php8.4-fpm installed, and have you tried installing it?

So why did it disappear when my script has not changed a bit, why was it previously there

I'm not psychic; I don't know what the script does. What commands does it run? Does it use apt? Are you installing PHP from Ondrej's PPA or Ubuntu archives?

A date on its own is means nothing. Don't get fixated on it and find out what's actually wrong.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

20h ago

Laravel From Scratch 2026 source code

@vincent15000 Every developer has repositories on their local computer. That .git directory in your project is a Git repository.

GitHub, GitLab, etc. are hosting platforms.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1d ago

How to modify Session middleware for waking up a serverless database without blocking UI

I must encrypt session data and I don't know if there is a different driver I can use for sessions while keeping the session data encrypted (and not paying for an additional service like Redis). I would prefer not to use cookies to avoid the additional work of providing cookie notices.

Encryption isn't an issue. You can encrypt session data or not, it works the same for any session storage. Except for cookie sessions, since Laravel always encrypts cookies.

I don't recommend cookie sessions (meaning session data kept in cookie contents), but you don't need notices for cookies that are necessary for the site to function. Plus your site is already using cookies. That's how Laravel identifies the user, as do most web apps.

If you have a filesystem available, file-based sessions should work well.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1d ago

How to modify Session middleware for waking up a serverless database without blocking UI

The database takes 30 seconds to start from a shut-down state. To save on database costs, the database shuts down after it has not received a query for 1 hour.

It doesn't sound like there's a lot of traffic if the DB can be idle for an hour. How much money could you save doing this? I'd at least set minimum capacity to 1.

You could also get a VPS for $5 a month and run your DB there if you're comfortable with Linux and know how to configure TLS and firewalls. My impression is that you don't need horizontal scaling right now.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1d ago

Site not receiving events in prod

Can you describe your production setup?

In local development, your browser typically connects directly to the local Reverb server. In production, you're usually going through Nginx, which handles TLS and proxies traffic to the Reverb server, which only listens on local connections.

Is that the setup you have?

What does the WebSocket connection in your browser's network tab look like (Request URL, Status Code, response headers)?

What do the MakeBid and EndAuction events in Laravel look like, especially their broadcastOn methods?

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1d ago

How to modify Session middleware for waking up a serverless database without blocking UI

Are you sure cache isn't what you are after? For session data to be displayed just load the page that uses that session data. I don't understand why it would take 30 seconds.

If other data needs storing for retrieval use another table specific for that. You should never have to "query" sessions as they are available anyway.

Read the first paragraph where they describe their setup. Are you familiar with the concept of serverless?

They're using a serverless database that apparently scales to zero and has to restart on demand. I'd never try to run an app like that if the database is needed for regular browsing. They could use a different session driver, but that doesn't help much if the database is used for anything else. A 30-second wait time is an automatic disqualifier, no matter how infrequent.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3d ago

How to test Cache memoization

If you want to run performance benchmarks, Laravel has utilities for it:

https://laravel.com/docs/13.x/helpers#benchmarking

Cache::memo() stores retrieved values in memory so that the underlying cache store is only hit once per record per request. It'll only have an effect if you try to fetch the same record multiple times in a single request.

You might see a big difference in the benchmarks if you crank up the number of iterations, but that's probably misleading. There might be no real performance benefit in practice.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3d ago

Missing /var/run/php-fpm.sock after reboot

You keep telling me how things should be, sure, but I already know that

There's no need to get snappy. I'm explaining what you need since you clearly don't know it.

I'm telling you how things are right now, so the big question is have you actually tried to install Nginx vs Apache on 22.04 after my OP?

I've installed both countless times on Ubuntu and other distros. But this has nothing to do with the installation of either. It has to do with php-fpm, or how it's used.

Here's what you need to do:

  • If php-fpm (or php8.4-fpm) isn't installed, you need to install it.
  • If it is installed, you need to start it.
  • If the service is running but the socket file is in another location, e.g. /var/run/php/php8.4-fpm.sock, you need to fix the path in your Nginx config.

The only useful pieces of information you've given so far are:

  • /var/run/php-fpm.sock no longer exists and your app doesn't work because of that.
  • There's no php-fpm service.

I can't tell you exactly what is wrong just based on that.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

4d ago

Missing /var/run/php-fpm.sock after reboot

If you had this file before the reboot:

/var/run/php-fpm.sock

Then you definitely had php-fpm running earlier.

You need php-fpm to run a Laravel app – or any PHP app for that matter – through Nginx. There are alternatives, but php-fpm is by far the most popular choice.

As I mentioned, the service may have a different name, such as php8.4-fpm. You can look for it:

systemctl list-unit-files | grep php

If you updated PHP and accidentally uninstalled php-fpm, you need to reinstall it.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

5d ago

Missing /var/run/php-fpm.sock after reboot

Start the php-fpm service:

sudo systemctl start php-fpm

Then enable it so it starts automatically on boot:

sudo systemctl enable php-fpm

This is assuming the service is named php-fpm in your system, which it probably is if the socket file was named php-fpm.sock before you rebooted. Often the service is versioned instead, e.g. php8.4-fpm.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

5d ago

Can I get a job with a resume with a few web development projects, github pull request merges that fixed issues, and with no college degree?

Understanding source code management, collaboration workflows, and version control practices might.

That's not important for newcomers. They'll learn about it on their first job. What matters is if they know the fundamentals of programming in whatever domain they're applying to.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

6d ago

JussiMannisto's avatar

JussiMannisto liked a comment+100 XP

1w ago

Can I code a web application from these cloud frameworks? Google AWS Microsoft

I would suggest code an app first following MVC and laravel conventions which is usually all that is needed. Then do any evaluations on the app. You may be jumping ahead of yourself.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1w ago

Can I code a web application from these cloud frameworks? Google AWS Microsoft

So if I decide to follow the aws well-architected best practices (...) I will be able to deploy my Laravel/Nextjs to the EC2 server through SSH or through Github Actions?

These questions make no sense. You can deploy apps through GitHub actions or over SSH. AWS guidelines, let alone KPIs, have nothing to do with it.

I don't think I've seen you (@june92 or @june23) ask a single programming-related question on this forum. But you keep bringing up terms and buzzwords in wrong contexts. Reading random articles without understanding the context isn't learning.

Have you ever finished a complete app with Laravel? You should start with that.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1w ago

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1w ago

Prevent Users From Opening the Same Test in Multiple active Tabs?

As my client do not want to increase the payment cost for the pusher so he denies for this.

Reverb is free.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1w ago

I am sorry this is way off topic. But is this link that can be downloaded and installed malware?

If you think it's a link to malware, which it probably is, please don't spread it further.

What do you expect people to do with it? Download and install it on their own computers to help you?

Should I continue my conversation with this person?

Oh come on.

If you want to install an app, install it from the official website.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

2w ago

Executing app resulting from app:build results in a runtime error

Do you, though? In which path is it? The error clearly says it doesn't exist, or it's not readable due to improper permissions.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3w ago

Can't browse site after clonning git repository

You're mixing yarn and npm, which seems weird to me. Use npm run dev instead of yarn dev.

The bundler is complaining about not finding resources/admin/sass/admin.scss. Does it exist?

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3w ago

Is it good having approximately 900 lines of a function?

Anyone trying to follow that method is going to have a really hard time. And that someone might be you two years from now.

Right now you're doing everything from control flow to low-level operations within the create() method. I'd refactor it so it only handles the top-level logic, and all heavy lifting is delegated to local methods. This makes the code more readable and also naturally comments it. Example:

if (array_key_exists('profile_image', $data['user'])) {
	$storageUsed = $this->uploadImage($data);
}

If you need to modify the $data array in a subtask, you can pass it as a reference:

protected function doSomething(array &$data): void {
	$data['user']['something'] = true;
}
JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3w ago

Connect to postgres cluster

I was asking why you added that option. It's not in the database config file by default. Did you read what it does from the Postgres docs?

You've set target_session_attrs to read-write for all connections, which means you cannot connect to the hosts you defined under read if they're read-only connections.

You also have a separate host array at the root level in addition to read and write hosts. I don't know Laravel interprets this, but it might mess things up. I recommend you read the docs before continuing.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3w ago

Connect to postgres cluster

What are you trying to achieve by including it to begin with?

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3w ago

I accidentally deleted a Controller. How to recover?

Oh, you're right: thread.

@adamnet You keep making the same mistake and asking the same question. Either accept that you'll occasionally lose work, or start using version control. If you want to be a serious developer, learn version control.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

3w ago

I accidentally deleted a Controller. How to recover?

If you use version control, such as Git, recovery is easy. Every developer should always use version control, even if they're working alone.

Another easy way is through an IDE. PhpStorm has a local history that shows file deletions, which you can revert. VS Code is a bit worse in this regard, but it's still possible.

Otherwise, you might be able to do it with some recovery tool. Recovering deleted files is less likely on SSDs than HDDs. Your best bet is to google "undelete tool" and try something to recover it. Recovery becomes less and less likely the longer you keep using the device.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

4w ago

Connect to postgres cluster

You have this piece of config:

'options' => [
	'target_session_attrs' => 'read-write',
],

Why is it used?

You haven't overridden target_session_attrs for the read connections, so I think they also have the read-write attribute, although I haven't tested it. And since those are read-only connections, the connections should fail.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

4w ago

Connect to postgres cluster

@vincent15000 Master (a.k.a. primary) and replica (a.k.a. slave) are basic concepts in database replication. Replica servers replicate data from primary server(s). The old terms are master/slave, the modern terms are primary/replica.

@Michael88 What does "it fails" mean? What actually happens?

And what do you mean by master switching to replica? Laravel uses a read connection by default. It only switches to the write connection when you write something to the DB. And all subsequent reads also use the write connection since you have the sticky option set (which is good).

JussiMannisto's avatar

JussiMannisto liked a comment+100 XP

4w ago

Event-Driven Architecture, do I need it?

I think you should learn how to code, and then use AI as a tool, and not as a developer.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Laravel Website Suddenly Slow After Server Migration – Possible PPA Launchpad Issue with PHP 7.4

Given this behavior, I’m wondering if this could be related to the PPA Launchpad issue. Am I thinking in the right direction?

No. That's only relevant when you're installing packages on Linux. It has no effect on your app after that.

JussiMannisto's avatar

JussiMannisto was awarded Best Answer+1000 XP

1mo ago

How is it possible to prevent TailwindCSS from loading Figtree font from google ?

Your app isn't involved here: the font is being loaded from some Chrome extension. It's not showing up in incognito mode because extensions are disabled there by default.

So the only solution is to disable the extension, whatever it is.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

How is it possible to prevent TailwindCSS from loading Figtree font from google ?

Your app isn't involved here: the font is being loaded from some Chrome extension. It's not showing up in incognito mode because extensions are disabled there by default.

So the only solution is to disable the extension, whatever it is.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

How do we handle this repetition?

As mentioned, route model binding is the solution.

If you want to use usernames in the URLs instead of IDs, you can do it like this:

Route::get('/users/{user:username}/comments', [UserController::class, 'comments']);
JussiMannisto's avatar

JussiMannisto was awarded Best Answer+1000 XP

1mo ago

Subtle bug in orWhere subquery?

You need to nest orWhere conditions in a where condition. Something like this:

$products = Product::where('parent_id', '!=', 0)
	->whereHas('flags', function ($query) use ($messages) {
		$query
			->where('is_valid', true)
			->where(function ($query) use ($messages) {
				foreach ($messages as $message) {
					$query->orWhere('message', 'LIKE', $message);
				}
			});
	})
	->get();

I might separate the message condition to a scope:

// Flag.php
use Illuminate\Database\Eloquent\Attributes\Scope;

#[Scope]
protected function messageLike(Builder $query, ...$messages): void {
	$query->where(function ($query) use ($messages) {
		foreach ($messages as $message) {
			$query->orWhere('name', 'LIKE', $message.'%');
		}
	});
}

// The query becomes a bit cleaner:
$products = Product::where('parent_id', '!=', 0)
	->whereHas('flags', fn($query) => $query
		->where('is_valid', true)
		->messageLike(...$messages)
	)
	->get();

P.S. parent_id should be a nullable column. If you're using 0 to denote no parent, you can't use a foreign key on the column.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Subtle bug in orWhere subquery?

You need to nest orWhere conditions in a where condition. Something like this:

$products = Product::where('parent_id', '!=', 0)
	->whereHas('flags', function ($query) use ($messages) {
		$query
			->where('is_valid', true)
			->where(function ($query) use ($messages) {
				foreach ($messages as $message) {
					$query->orWhere('message', 'LIKE', $message);
				}
			});
	})
	->get();

I might separate the message condition to a scope:

// Flag.php
use Illuminate\Database\Eloquent\Attributes\Scope;

#[Scope]
protected function messageLike(Builder $query, ...$messages): void {
	$query->where(function ($query) use ($messages) {
		foreach ($messages as $message) {
			$query->orWhere('name', 'LIKE', $message.'%');
		}
	});
}

// The query becomes a bit cleaner:
$products = Product::where('parent_id', '!=', 0)
	->whereHas('flags', fn($query) => $query
		->where('is_valid', true)
		->messageLike(...$messages)
	)
	->get();

P.S. parent_id should be a nullable column. If you're using 0 to denote no parent, you can't use a foreign key on the column.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Need help setting up for prod

I looked at your config briefly and noticed some things.

proxy_pass hype://0.0.0.0:6001; 

That address doesn't make sense in this context. Since your Reverb server is running locally, replace 0.0.0.0 with 127.0.0.1.

0.0.0.0 is a wildcard meaning "all IPv4 network interfaces" when listening on incoming traffic. But it doesn't work as a proxying target: you need an actual IP address for that.

Failed to listen on "tcp://127.0.0.1:8080": Address already in use (EADDRINUSE)

When are you getting this error? Is it when Supervisor tries to start the Reverb server?

That error means some other process is already listening on that port. Run this command to see what's up:

sudo ss -tulpn 'sport = :8080'

Other minor things:

listen \[::\]:443 quic;
listen 443 quic;
http3 off;

These settings are contradictory. You're opening two QUIC sockets for IPv4 and IPv6, but then you're turning off HTTP/3 support – the protocol that would actually use QUIC.

  if (-f $request_filename) {  
    break;  
  }  

This does nothing. Your try_files rule already routes everything to Laravel if the file doesn't exist on disk.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Querying DB

What's the use case? It might make more sense to do some of this in code rather than SQL.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Prefix for session cookie

Are you serving the site over https? Or are you using something like http://localhost?

Browsers ignore the secure flag of cookies on localhost. They treat *.localhost domains as special cases and don't enforce the secure requirement because it makes local development easier. But they should still respect cookie prefixes (if they're supported to begin with). If you're not using https, that would explain why your session cookies aren't working.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Is it okay to have several Blade views, Routes and Controllers for the same thing for different Authority?

When user goes to their roles page and go to a specific role panel, I will put the hidden roleId on forms, so I can check in authorization, if this user have this role, and if this role has the permission needed for the action. How is it? Is it a bad practice?

Don't do this. Anyone could modify the hidden input in the page source and spoof a different role.

You don't need to add any hidden inputs. Your backend already knows who the user is, and you can use Laravel's built-in authorization features. I strongly recommend you read the documentation first:

https://laravel.com/docs/13.x/authorization

But I can give you a quick rundown.

Below is a simple policy class for a Post model. It has just one authorization check: can a user edit a post. Editing is allowed if the user is a super-admin or the original author of the post.

class PostPolicy {
    public function edit(User $user, Post $post): bool {
        if ($user->role === 'super-admin')
			return true;
		 
		return $user->id === $post->user_id;
    }
}

Here's how you register the policy on the model:

use Illuminate\Database\Eloquent\Attributes\UsePolicy;

#[UsePolicy(PostPolicy::class)]
class Post extends Model {
    ...
}

Once you have the policy registered, you can do authorization checks in code, middleware, and Blade templates. Some examples:

// Authorization check in middleware:
Route::patch('/posts/{post}', [PostController::class, 'update'])
	->can('edit', 'post')
	->name('posts.update');
	
// Authorization check in a controller:
if ($request->user()->can('edit', $post)) {
	...
}

// Authorization check in Blade:
@can('update', $post)
	...
@endcan

The docs have all the details.

JussiMannisto's avatar

JussiMannisto was awarded Best Answer+1000 XP

1mo ago

Security problem with this code ?

What kind of attack are you talking about?

Users can do anything with their own front end, so they can of course submit the form anywhere. That's why you validate and authorize everything server-side.

On the front end, what you need to worry about is code injection that could affect other users (XSS).

JussiMannisto's avatar

JussiMannisto was awarded Best Answer+1000 XP

1mo ago

Laravel / InertiaJS / VueJS - 502 Bad Gateway

It may be caused by the asset preload headers set by Inertia. Together with other headers, they can exceed the default FastCGI buffer size of Nginx. You can try increasing the size in the http block in nginx.conf, e.g.

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

Then restart Nginx.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Laravel / InertiaJS / VueJS - 502 Bad Gateway

Why would your choice of session driver matter? Unless you use the cookie driver, it should make no difference whatsoever.

Nginx is telling you what's wrong: your backend (upstream) is sending response headers that are too big. Either increase the buffer size in Nginx or remove the AddLinkHeadersForPreloadedAssets middleware in Laravel. I don't recommend the latter if you care about performance.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Laravel / InertiaJS / VueJS - 502 Bad Gateway

It may be caused by the asset preload headers set by Inertia. Together with other headers, they can exceed the default FastCGI buffer size of Nginx. You can try increasing the size in the http block in nginx.conf, e.g.

fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;

Then restart Nginx.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Developing on Linux

That error message told you what's wrong and what you need to do. You're missing PHP's XML extension.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Developing on Linux

You didn't say what went wrong with Breeze and the starter kits.

JussiMannisto's avatar

JussiMannisto was awarded Best Answer+1000 XP

1mo ago

How to check if SSR is used ?

View the page source. If you see fully rendered html, SSR works. If you see an empty div in the body, it's not working.

Note that only the first page is rendered on the server, and other pages are rendered client-side when you navigate to them. This is by design.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Is it worth it to learn all the courses and coding when AI can make the production level application

For AI there no like easy question or hard question, If you ask questions and it runs query from its database and calculate those data and pass it to you.

That's not how an LLM works. It doesn't run queries. It's a stochastic text predictor that produces text one token at a time. It's a pattern completion machine. The appearance of understanding is an illusion.

This is also true, But As if now you can get any kind solution with AI,

No. AI gives you text output. Nothing beyond that is guaranteed.

AI gets things wrong, hallucinates, tries to solve every problem locally rather than globally, etc. Some issues may be solvable with tooling, but some may be fundamentally beyond the capabilities of the current text predictor approach. These LLM's aren't AGI.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

1mo ago

Is it worth it to learn all the courses and coding when AI can make the production level application

Then its like waste time to learn all these stuff which can be automated in future.

If it feels like a waste of time to learn what happens under the hood, software development might not be the right career path for you.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

2mos ago

Is it worth it to learn all the courses and coding when AI can make the production level application

As of today, AI agents can't make proper apps on their own. What they can do is produce junk that passes tests. To use it for any proper product, you have to understand the code and correct its issues.

It's clear that AI will be useful, but the hype is completely overblown. If you were to go back and read the marketing from two years ago, you'd think you have no future in tech if you didn't use [insert any AI tool hot at the time]. Now those AI models are obsolete, and if you spent the time learning the fundamentals of computer science instead, you'd be much better off.

Some of the recent layoffs in the tech sector can be attributed to pandemic-era over-hiring and the general downturn in the US economy. But I'm sure the over-hyping of generative AI is partly to blame. I believe we'll see more service degradation over the following years.

What you should do ultimately depends on your goals. If you're a non-programmer who wants something on the screen, you may not need to understand the code. I just don't see anyone hiring an "AI prompter" who's helpless when something doesn't work.

JussiMannisto's avatar

JussiMannisto wrote a reply+100 XP

2mos ago

GraphQL 🤔

"They" are being silly.