<?xml version="1.0" encoding="UTF-8"?><feed
	xmlns="http://www.w3.org/2005/Atom"
	xmlns:thr="http://purl.org/syndication/thread/1.0"
	xml:lang="en-US"
	>
	<title type="text">PHP Magazine Network</title>
	<subtitle type="text"></subtitle>

	<updated>2026-11-19T02:37:10Z</updated>

	<link rel="alternate" type="text/html" href="https://phpmagazine.net" />
	<id>https://phpmagazine.net/feed/atom</id>
	<link rel="self" type="application/atom+xml" href="https://phpmagazine.net/feed/atom" />

	<generator uri="https://wordpress.org/" version="7.1.5">WordPress</generator>
	<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[Your Calendar Is Not Your Capacity]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/freelance-developer-client-support-capacity.html" />

		<id>https://phpmagazine.net/?p=35394</id>
		<updated>2026-11-17T00:43:47Z</updated>
		<published>2026-11-19T20:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="Freelancing" /><category scheme="https://phpmagazine.net" term="capacity planning" /><category scheme="https://phpmagazine.net" term="client support" /><category scheme="https://phpmagazine.net" term="developer productivity" /><category scheme="https://phpmagazine.net" term="software consulting" />
		<summary type="html"><![CDATA[A freelance developer looks at next week’s calendar. There are only two meetings and a project deadline on Friday. A new client asks whether a small urgent request can be completed on Tuesday, and the calendar appears to say yes. But the calendar does not show that two existing clients expect prompt support, a release [&#8230;]]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/freelance-developer-client-support-capacity.html"><![CDATA[

<p class="wp-block-paragraph">A freelance developer looks at next week’s calendar. There are only two meetings and a project deadline on Friday. A new client asks whether a small urgent request can be completed on Tuesday, and the calendar appears to say yes.</p>



<p class="wp-block-paragraph">But the calendar does not show that two existing clients expect prompt support, a release is scheduled for Wednesday, and a proposal needs to be prepared. The apparent free space is already carrying obligations. Accepting another commitment without seeing those obligations can make every client less well served.</p>



<h2 class="wp-block-heading">Separate booked hours from promised availability</h2>



<p class="wp-block-paragraph">Booked work has a known place in the schedule: a workshop, a deployment or a planned development task. Availability is different. A client may be paying for a response within a business day without knowing when the request will arrive or how long it will take to resolve.</p>



<p class="wp-block-paragraph">That promise has a capacity cost even during a quiet week. The developer may need to monitor a channel, interrupt planned work, investigate an issue and communicate a response. A response-time commitment should therefore be planned separately from the estimated hours required to complete the work.</p>



<p class="wp-block-paragraph">In a hypothetical arrangement, a developer supports three clients and promises each an initial response within four business hours. The developer does not necessarily need to reserve twelve hours every day, but must consider what happens if two urgent requests arrive during the same morning. The answer cannot be “both are first.”</p>



<h2 class="wp-block-heading">Define what a response actually means</h2>



<p class="wp-block-paragraph">An initial response might confirm receipt, assess impact and explain the next step. It is not necessarily a repair, a completed feature or a guaranteed resolution time. The agreement should make that distinction understandable to both parties.</p>



<p class="wp-block-paragraph">Also define the support window, accepted contact channels, severity levels and the route for emergencies. If the freelancer works Monday to Friday, a request sent on Saturday should not silently create a Saturday obligation. If the client needs round-the-clock coverage, a solo developer should assess whether they can provide it sustainably or whether a different support arrangement is needed.</p>



<h2 class="wp-block-heading">Protect time for work that cannot be interrupted</h2>



<p class="wp-block-paragraph">Writing a migration, investigating a complex defect or reviewing a security-sensitive change may require sustained attention. A schedule filled entirely with client meetings and promised response windows can leave no suitable time for the work those clients expect.</p>



<p class="wp-block-paragraph">Block focused work explicitly and decide how support is monitored during that period. One option is to check a support queue at agreed intervals while providing a separate channel for genuinely urgent incidents. Another is to offer a slower response commitment at a lower level of service. The appropriate model depends on the clients and the work; the important point is to make the trade-off explicit.</p>



<h2 class="wp-block-heading">Keep a small capacity ledger</h2>



<p class="wp-block-paragraph">A spreadsheet or calendar can show the commitments that are easy to overlook. For each client, record the support window, response target, current project deadlines, expected release dates and any known absences. Add time for administration, learning and recovery from unexpected work.</p>



<p class="wp-block-paragraph">Review the ledger before accepting a new promise. Ask what could move if an incident arrives, which client would be contacted and whether another person can provide coverage. A buffer is not wasted capacity: it is the space that allows an unpredictable service to remain dependable.</p>



<h2 class="wp-block-heading">Renegotiate before the schedule breaks</h2>



<p class="wp-block-paragraph">If demand repeatedly exceeds the available time, show the client the pattern and propose concrete choices. The client might accept a longer response window, reserve additional capacity, reduce the scope of support or work with a team that can provide coverage. A freelancer can also decline a new project when existing promises leave too little room.</p>



<p class="wp-block-paragraph">Capacity planning is not about filling every hour. It is about making promises that can survive an ordinary week when the unexpected happens.</p>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/freelance-developer-client-support-capacity.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/freelance-developer-client-support-capacity.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[When Business Rules Grow: Designing a Scheduling Domain in PHP]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/when-business-rules-grow-designing-a-scheduling-domain-in-php.html" />

		<id>https://phpmagazine.net/?p=35427</id>
		<updated>2026-11-17T03:01:05Z</updated>
		<published>2026-11-19T14:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="PHP Architecture Lab" /><category scheme="https://phpmagazine.net" term="appointment booking" /><category scheme="https://phpmagazine.net" term="business rules" /><category scheme="https://phpmagazine.net" term="Domain Modeling" /><category scheme="https://phpmagazine.net" term="PHP Architecture" /><category scheme="https://phpmagazine.net" term="PHP scheduling" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/when-business-rules-grow-designing-a-scheduling-domain-in-php.html"><![CDATA[

<p class="wp-block-paragraph"><strong>PHP Architecture Lab — Episode 02.</strong> Our appointment booking system works. Citizens can choose a date, see available time slots, and reserve an appointment. But the public-service office has just introduced a few new requirements, and the original implementation is beginning to show its limits.</p>



<p class="wp-block-paragraph">Some appointments last 30 minutes. Others require 45 or 60 minutes. The office closes on public holidays. Opening hours differ between weekdays, and administrators occasionally close a counter for part of the day.</p>



<p class="wp-block-paragraph">Nothing in this list sounds especially complicated. Together, however, these requirements change the meaning of availability. A time slot is no longer merely a start time that does not appear in the database. It is an interval that must satisfy several business rules.</p>



<p class="wp-block-paragraph">In this second installment, we will evolve the application from Episode 01 into a small scheduling domain. We will keep the existing appointments table, introduce explicit scheduling rules, and explore why modeling intervals is more important than choosing a particular design pattern.</p>



<h2 class="wp-block-heading">The Requirement That Breaks Our First Design</h2>



<p class="wp-block-paragraph">Our original application generated appointments every 30 minutes between 09:00 and 17:00. It prevented two reservations with the same start time from using the same counter.</p>



<p class="wp-block-paragraph">Now consider these two reservations:</p>



<figure class="wp-block-table"><table><thead><tr><th>Appointment</th><th>Start</th><th>Duration</th><th>End</th></tr></thead><tbody><tr><td>Document verification</td><td>10:00</td><td>60 minutes</td><td>11:00</td></tr><tr><td>Identity verification</td><td>10:30</td><td>30 minutes</td><td>11:00</td></tr></tbody></table></figure>



<p class="wp-block-paragraph">The start times differ, so the unique database index created in Episode 01 would allow both appointments. But they occupy the same counter between 10:30 and 11:00.</p>



<p class="wp-block-paragraph">We have discovered a domain invariant: <strong>a resource cannot have two active appointments whose time intervals overlap.</strong></p>



<p class="wp-block-paragraph">This is more fundamental than the original implementation detail of generating 30-minute slots.</p>



<h2 class="wp-block-heading">1. Model Appointments as Time Intervals</h2>



<p class="wp-block-paragraph">A useful representation is the half-open interval <code class="" data-line="">[start, end)</code>. The start is included, while the end is excluded. This means an appointment ending at 11:00 does not conflict with another beginning exactly at 11:00.</p>



<p class="wp-block-paragraph">Two appointments overlap if:</p>



<pre class="wp-block-code"><code class="" data-line="">$firstStart &lt; $secondEnd
    &amp;&amp; $secondStart &lt; $firstEnd;
</code></pre>



<p class="wp-block-paragraph">Instead of scattering this formula across controllers and SQL statements, we can express it with a small domain object.</p>



<pre class="wp-block-code"><code class="" data-line="">&lt;?php
declare(strict_types=1);

final readonly class TimeInterval
{
    public function __construct(
        public DateTimeImmutable $start,
        public DateTimeImmutable $end
    ) {
        if ($start &gt;= $end) {
            throw new InvalidArgumentException(
                &#039;Interval end must follow start&#039;
            );
        }
    }

    public function overlaps(self $other): bool
    {
        return $this-&gt;start &lt; $other-&gt;end
            &amp;&amp; $other-&gt;start &lt; $this-&gt;end;
    }

    public function contains(self $other): bool
    {
        return $this-&gt;start &lt;= $other-&gt;start
            &amp;&amp; $other-&gt;end &lt;= $this-&gt;end;
    }
}
</code></pre>



<p class="wp-block-paragraph">This class has no knowledge of databases, HTTP, public holidays, or appointment services. Its responsibility is to provide reliable interval operations. That makes it small, testable, and reusable.</p>



<h2 class="wp-block-heading">2. Represent Services Explicitly</h2>



<p class="wp-block-paragraph">Our first version used a fixed appointment duration. Now different services require different amounts of time.</p>



<p class="wp-block-paragraph">We could put a series of conditional statements directly inside the booking controller. But service durations belong to the business domain, not to HTTP routing.</p>



<pre class="wp-block-code"><code class="" data-line="">final readonly class AppointmentService
{
    public function __construct(
        public string $code,
        public int $durationMinutes
    ) {
        if ($code === &#039;&#039; || $durationMinutes &lt;= 0) {
            throw new InvalidArgumentException(
                &#039;Invalid appointment service&#039;
            );
        }
    }
}

$services = &#091;
    &#039;DOCUMENT_CHECK&#039; =&gt; new AppointmentService(
        &#039;DOCUMENT_CHECK&#039;,
        30
    ),
    &#039;IDENTITY_VERIFY&#039; =&gt; new AppointmentService(
        &#039;IDENTITY_VERIFY&#039;,
        45
    ),
    &#039;COMPLEX_CASE&#039; =&gt; new AppointmentService(
        &#039;COMPLEX_CASE&#039;,
        60
    )
];
</code></pre>



<p class="wp-block-paragraph">These values are still configured in PHP. That is acceptable for the current lab. An administrator-managed catalog can come later without changing the concept of an appointment service.</p>



<h2 class="wp-block-heading">3. Define Opening Hours and Holidays</h2>



<p class="wp-block-paragraph">A scheduling domain needs a precise definition of when reservations are permitted. We will represent weekly opening hours by ISO weekday number, where Monday is 1 and Sunday is 7.</p>



<p class="wp-block-paragraph">We will also keep a list of full-day closures. The dates below are illustrative laboratory data, not an authoritative government holiday calendar. A production implementation should load the correct jurisdiction-specific rules, including observed holidays and administrative exceptions.</p>



<pre class="wp-block-code"><code class="" data-line="">final readonly class SchedulePolicy
{
    public function __construct(
        private DateTimeZone $timezone,
        private array $weeklyHours,
        private array $closedDates
    ) {}

    public function openingIntervals(
        DateTimeImmutable $day
    ): array {
        $localDay = $day-&gt;setTimezone($this-&gt;timezone);
        $date = $localDay-&gt;format(&#039;Y-m-d&#039;);

        if (in_array($date, $this-&gt;closedDates, true)) {
            return &#091;];
        }

        $weekday = (int) $localDay-&gt;format(&#039;N&#039;);
        $hours = $this-&gt;weeklyHours&#091;$weekday] ?? &#091;];

        $intervals = &#091;];

        foreach ($hours as &#091;$opening, $closing]) {
            $start = new DateTimeImmutable(
                &quot;$date $opening&quot;,
                $this-&gt;timezone
            );

            $end = new DateTimeImmutable(
                &quot;$date $closing&quot;,
                $this-&gt;timezone
            );

            // Reject normalized or ambiguous schedule input
            // through configuration validation in production.
            $intervals&#091;] = new TimeInterval($start, $end);
        }

        return $intervals;
    }

    public function timezone(): DateTimeZone
    {
        return $this-&gt;timezone;
    }
}
</code></pre>



<p class="wp-block-paragraph">Configure the office&#8217;s local schedule:</p>



<pre class="wp-block-code"><code class="" data-line="">$policy = new SchedulePolicy(
    new DateTimeZone(&#039;America/Toronto&#039;),
    &#091;
        1 =&gt; &#091;&#091;&#039;09:00&#039;, &#039;12:00&#039;], &#091;&#039;13:00&#039;, &#039;17:00&#039;]],
        2 =&gt; &#091;&#091;&#039;09:00&#039;, &#039;12:00&#039;], &#091;&#039;13:00&#039;, &#039;17:00&#039;]],
        3 =&gt; &#091;&#091;&#039;09:00&#039;, &#039;12:00&#039;], &#091;&#039;13:00&#039;, &#039;17:00&#039;]],
        4 =&gt; &#091;&#091;&#039;10:00&#039;, &#039;12:00&#039;], &#091;&#039;13:00&#039;, &#039;18:00&#039;]],
        5 =&gt; &#091;&#091;&#039;09:00&#039;, &#039;12:00&#039;], &#091;&#039;13:00&#039;, &#039;16:00&#039;]]
    ],
    &#091;
        &#039;2026-12-25&#039;,
        &#039;2027-01-01&#039;
    ]
);
</code></pre>



<p class="wp-block-paragraph">The office now has working intervals, not just a single opening and closing time. A lunch break is represented as a gap between intervals. A service requiring 60 minutes cannot begin at 11:30 if the office closes at noon, even if the start time itself appears valid.</p>



<h2 class="wp-block-heading">4. Generate Availability from Business Rules</h2>



<p class="wp-block-paragraph">We can now replace the original slot generator. Our new availability calculation needs a scheduling policy, an appointment service, and a list of already occupied intervals.</p>



<p class="wp-block-paragraph">For presentation purposes, candidate start times will be generated every 15 minutes. The interval between possible start times is independent of the duration of an appointment.</p>



<pre class="wp-block-code"><code class="" data-line="">final class AvailabilityCalculator
{
    public function findSlots(
        DateTimeImmutable $date,
        AppointmentService $service,
        SchedulePolicy $policy,
        array $occupied,
        array $closures = &#091;]
    ): array {
        $slots = &#091;];
        $now = new DateTimeImmutable(&#039;now&#039;);

        foreach ($policy-&gt;openingIntervals($date) as $window) {
            for (
                $start = $window-&gt;start;
                $start &lt; $window-&gt;end;
                $start = $start-&gt;modify(&#039;+15 minutes&#039;)
            ) {
                $end = $start-&gt;modify(
                    &#039;+&#039; . $service-&gt;durationMinutes . &#039; minutes&#039;
                );

                $candidate = new TimeInterval($start, $end);

                if (!$window-&gt;contains($candidate)) {
                    continue;
                }

                if ($start &lt;= $now) {
                    continue;
                }

                if ($this-&gt;hasConflict(
                    $candidate,
                    &#091;...$occupied, ...$closures]
                )) {
                    continue;
                }

                $slots&#091;] = $start-&gt;format(DATE_ATOM);
            }
        }

        return $slots;
    }

    private function hasConflict(
        TimeInterval $candidate,
        array $blocked
    ): bool {
        foreach ($blocked as $interval) {
            if ($candidate-&gt;overlaps($interval)) {
                return true;
            }
        }

        return false;
    }
}
</code></pre>



<p class="wp-block-paragraph">The calculation now has a different shape from Episode 01. We no longer assume that a free start time means a free appointment. Instead, we construct the full candidate interval and check it against opening hours, other bookings, and temporary closures.</p>



<p class="wp-block-paragraph">We have also made the scheduling calculation independent of PDO. It accepts occupied intervals as data. This makes it possible to test the rules without a database connection.</p>



<h2 class="wp-block-heading">5. Connect the Calculator to Existing Appointments</h2>



<p class="wp-block-paragraph">We can continue using the appointments table introduced in Episode 01. Rather than retrieving only reserved start times, the data-access code now retrieves full intervals.</p>



<pre class="wp-block-code"><code class="" data-line="">function loadOccupiedIntervals(
    PDO $pdo,
    int $resourceId,
    DateTimeImmutable $start,
    DateTimeImmutable $end
): array {
    $utc = new DateTimeZone(&#039;UTC&#039;);

    $statement = $pdo-&gt;prepare(
        &#039;SELECT starts_at_utc, ends_at_utc
         FROM appointments
         WHERE resource_id = ?
           AND starts_at_utc &lt; ?
           AND ends_at_utc &gt; ?&#039;
    );

    $statement-&gt;execute(&#091;
        $resourceId,
        $end-&gt;setTimezone($utc)
            -&gt;format(&#039;Y-m-d H:i:s&#039;),
        $start-&gt;setTimezone($utc)
              -&gt;format(&#039;Y-m-d H:i:s&#039;)
    ]);

    $intervals = &#091;];

    foreach ($statement-&gt;fetchAll() as $row) {
        $intervals&#091;] = new TimeInterval(
            new DateTimeImmutable(
                $row&#091;&#039;starts_at_utc&#039;],
                $utc
            ),
            new DateTimeImmutable(
                $row&#091;&#039;ends_at_utc&#039;],
                $utc
            )
        );
    }

    return $intervals;
}
</code></pre>



<p class="wp-block-paragraph">The overlap condition in SQL mirrors our domain-level rule. It retrieves appointments that start before the requested window ends and finish after the window begins.</p>



<p class="wp-block-paragraph">For the new availability endpoint, the application layer should construct the local calendar day, convert its boundaries to UTC for the query, and pass the resulting intervals to <code class="" data-line="">AvailabilityCalculator</code>. The booking operation must use the same calculator to validate the requested appointment immediately before insertion.</p>



<p class="wp-block-paragraph">This is a meaningful architectural separation. The database knows how to retrieve reservations. The scheduling domain knows whether a proposed interval is valid. HTTP decides how to represent the result to the client.</p>



<h2 class="wp-block-heading">6. Add Administrative Closures Without Rewriting the Algorithm</h2>



<p class="wp-block-paragraph">Suppose an administrator needs to close a counter between 14:00 and 15:30 for maintenance, training, or an exceptional interruption.</p>



<p class="wp-block-paragraph">We do not need another branch in the scheduling algorithm. A closure is simply another blocked interval, passed separately from existing reservations.</p>



<pre class="wp-block-code"><code class="" data-line="">$tz = new DateTimeZone(&#039;America/Toronto&#039;);

$closures = &#091;
    new TimeInterval(
        new DateTimeImmutable(&#039;2026-11-23 14:00&#039;, $tz),
        new DateTimeImmutable(&#039;2026-11-23 15:30&#039;, $tz)
    )
];

$calculator = new AvailabilityCalculator();

$slots = $calculator-&gt;findSlots(
    new DateTimeImmutable(&#039;2026-11-23&#039;, $tz),
    $services&#091;&#039;IDENTITY_VERIFY&#039;],
    $policy,
    $occupiedIntervals,
    $closures
);
</code></pre>



<p class="wp-block-paragraph">A candidate appointment overlapping the closure will be rejected automatically. The availability algorithm does not care whether the blocking interval represents another citizen&#8217;s booking or an administrative closure.</p>



<p class="wp-block-paragraph">That flexibility comes from identifying the shared business concept: an interval during which the resource is unavailable.</p>



<h2 class="wp-block-heading">7. Test the Rules Before Adding More Infrastructure</h2>



<p class="wp-block-paragraph">One benefit of this design is that interval logic can be tested without an HTTP request or a database. Start with three essential cases.</p>



<pre class="wp-block-code"><code class="" data-line="">$tz = new DateTimeZone(&#039;UTC&#039;);

$booking = new TimeInterval(
    new DateTimeImmutable(&#039;2026-11-23 10:00&#039;, $tz),
    new DateTimeImmutable(&#039;2026-11-23 11:00&#039;, $tz)
);

$overlapping = new TimeInterval(
    new DateTimeImmutable(&#039;2026-11-23 10:30&#039;, $tz),
    new DateTimeImmutable(&#039;2026-11-23 11:30&#039;, $tz)
);

$adjacent = new TimeInterval(
    new DateTimeImmutable(&#039;2026-11-23 11:00&#039;, $tz),
    new DateTimeImmutable(&#039;2026-11-23 11:30&#039;, $tz)
);

assert($booking-&gt;overlaps($overlapping));
assert(!$booking-&gt;overlaps($adjacent));
assert($booking-&gt;contains($booking));
</code></pre>



<p class="wp-block-paragraph">In an automated test suite, use explicit assertions from PHPUnit or another testing framework rather than relying solely on PHP&#8217;s configurable <code class="" data-line="">assert()</code> behavior.</p>



<p class="wp-block-paragraph">The next tests should cover an appointment crossing a lunch break, a statutory holiday, a partial administrative closure, and a service longer than the remaining working window. Time-zone transitions deserve particular attention: local civil times can be ambiguous or nonexistent during daylight-saving changes. Production rules must define how to handle those cases instead of silently accepting normalized timestamps.</p>



<h2 class="wp-block-heading">8. What Should Change in the Database?</h2>



<p class="wp-block-paragraph">Our original schema already stores appointment end times, so we do not need to discard the database model. But the unique index on <code class="" data-line="">(resource_id, starts_at_utc)</code> is no longer a sufficient integrity rule.</p>



<p class="wp-block-paragraph">The new scheduling logic can recognize overlapping reservations. That does not mean the database can prevent two simultaneous requests from inserting overlapping intervals.</p>



<p class="wp-block-paragraph">This distinction is critical. A domain rule and its safe enforcement under concurrency are related but separate engineering concerns.</p>



<p class="wp-block-paragraph">For now, we retain the existing index as an additional safeguard and acknowledge its limitations. We should not claim that checking availability immediately before insertion guarantees an exclusive reservation.</p>



<p class="wp-block-paragraph">In the next installment, we will address overlapping bookings at the persistence boundary, compare database-specific locking and integrity mechanisms, and examine what happens when many users attempt to reserve the same capacity simultaneously.</p>



<h2 class="wp-block-heading">9. The Architectural Decision: Extract Rules, Not Everything</h2>



<p class="wp-block-paragraph">We have introduced three small concepts: <code class="" data-line="">TimeInterval</code>, <code class="" data-line="">SchedulePolicy</code>, and <code class="" data-line="">AvailabilityCalculator</code>. They exist because the business requirements now justify them.</p>



<p class="wp-block-paragraph">We have not introduced a dependency-injection container, a generic repository framework, a message broker, or separate microservices. None of those tools is necessary to understand the scheduling rules.</p>



<p class="wp-block-paragraph">Good modularity is not measured by how many interfaces an application contains. It is measured by whether important responsibilities can evolve independently, whether behavior can be tested reliably, and whether the implementation remains understandable.</p>



<p class="wp-block-paragraph">Our availability algorithm can now change without rewriting HTTP routing. The persistence mechanism can evolve without changing interval arithmetic. New service types can be introduced without duplicating scheduling logic.</p>



<p class="wp-block-paragraph">That is a useful architectural improvement, achieved without making the system unnecessarily complex.</p>



<h2 class="wp-block-heading">Next in PHP Architecture Lab</h2>



<p class="wp-block-paragraph">Our reservation system now understands appointment durations, opening hours, holidays, and blocked intervals. But imagine two citizens selecting the same available counter at almost exactly the same moment.</p>



<p class="wp-block-paragraph">Both requests could pass the scheduling checks before either reservation is inserted. Our domain model is correct, but the final result may still violate the rules.</p>



<p class="wp-block-paragraph">Episode 03 will investigate this problem: <strong>The Double-Booking Problem: Concurrency Without Global Locks.</strong> We will examine competing transactions, database constraints, and practical strategies for protecting reservations without unnecessarily restricting the entire application.</p>



<p class="wp-block-paragraph"><strong>PHP Architecture Lab — One application. Real decisions. Better architecture.</strong></p>



<h3 class="wp-block-heading">References</h3>



<ul class="wp-block-list">
<li><a href="https://www.php.net/manual/en/class.datetimeimmutable.php">PHP Manual — DateTimeImmutable</a></li>



<li><a href="https://www.php.net/manual/en/class.datetimezone.php">PHP Manual — DateTimeZone</a></li>



<li><a href="https://www.php.net/manual/en/pdo.transactions.php">PHP Manual — PDO Transactions</a></li>



<li><a href="https://www.sqlite.org/lang_expr.html">SQLite Documentation — SQL Expressions</a></li>
</ul>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/when-business-rules-grow-designing-a-scheduling-domain-in-php.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/when-business-rules-grow-designing-a-scheduling-domain-in-php.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[PSL 6.4: A Modern Standard Library for PHP, Beyond the Built-In Functions]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/psl-64-modern-php-standard-library-type-safety-async.html" />

		<id>https://phpmagazine.net/?p=35440</id>
		<updated>2026-11-17T12:11:45Z</updated>
		<published>2026-11-19T13:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="PHP Project Radar" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/psl-64-modern-php-standard-library-type-safety-async.html"><![CDATA[

<p class="wp-block-paragraph">PHP has never lacked built-in functions. Its standard library covers strings, arrays, dates, files, networking, cryptography, and dozens of other concerns. Yet the language&#8217;s long history has left developers navigating APIs that differ considerably in naming, argument order, return values, and error handling.</p>



<p class="wp-block-paragraph">Some functions return false on failure. Others throw exceptions. Array operations frequently combine transformation, filtering, mutation, and key handling in ways that require careful attention to documentation.</p>



<p class="wp-block-paragraph">For developers building strongly typed applications, these inconsistencies become more noticeable as projects grow.</p>



<p class="wp-block-paragraph"><strong>PSL, the PHP Standard Library project, proposes a more consistent collection of APIs for modern PHP development, including typed data structures, validation, asynchronous I/O, networking, and cryptographic operations.</strong></p>



<p class="wp-block-paragraph">The project is not part of PHP&#8217;s official core distribution, despite its name. It is an independent, MIT-licensed library installed through Composer.</p>



<p class="wp-block-paragraph">Its recent 6.x releases are particularly interesting because PSL has evolved from a collection of convenience functions into a broader application infrastructure library.</p>



<p class="wp-block-paragraph">For this edition of PHP Projects Radar, we examine the architecture, practical benefits, migration considerations, and operational risks of adopting PSL in production applications.</p>



<h2 class="wp-block-heading">The Problem Is Consistency, Not Missing Functionality</h2>



<p class="wp-block-paragraph">Consider a common PHP operation: filtering a collection of names.</p>



<pre class="wp-block-code"><code class="" data-line="">$names = &#091;&#039;alice&#039;, &#039;bob&#039;, &#039;charlie&#039;];

$result = array_filter(
    $names,
    fn (string $name): bool =&gt;
        mb_strlen($name) &gt; 3
);</code></pre>



<p class="wp-block-paragraph">This code works. However, array_filter preserves the original array keys, which may not be what the caller expects when producing a sequential list.</p>



<p class="wp-block-paragraph">Developers may need to call array_values afterward to normalize the result.</p>



<p class="wp-block-paragraph">PSL offers collection functions with more explicit distinctions between vectors, dictionaries, and other data structures.</p>



<pre class="wp-block-code"><code class="" data-line="">use Psl\Vec;
use Psl\Str;

$names = &#091;&#039;alice&#039;, &#039;bob&#039;, &#039;charlie&#039;];

$result = Vec\filter(
    $names,
    fn (string $name): bool =&gt;
        Str\length($name) &gt; 3
);</code></pre>



<p class="wp-block-paragraph">The difference is not dramatic in a small example. The argument for PSL becomes more substantial when developers use the same conventions across validation, collections, text processing, and asynchronous operations.</p>



<p class="wp-block-paragraph">Instead of remembering a variety of unrelated PHP behaviors, developers work with APIs designed around more consistent types and failure modes.</p>



<h2 class="wp-block-heading">A Major Architectural Change in Version 6</h2>



<p class="wp-block-paragraph">PSL 6.0 introduced an important change in how the project is distributed.</p>



<p class="wp-block-paragraph">Rather than requiring every application to install the entire library, the project introduced 61 independently installable Composer packages.</p>



<p class="wp-block-paragraph">Applications that only require type validation can install the relevant component without bringing in the complete networking and cryptography stack.</p>



<pre class="wp-block-code"><code class="" data-line="">composer require php-standard-library/type</code></pre>



<p class="wp-block-paragraph">Applications needing several components can install them individually, while developers who prefer the complete library can use:</p>



<pre class="wp-block-code"><code class="" data-line="">composer require php-standard-library/php-standard-library:^6.4</code></pre>



<p class="wp-block-paragraph">This modular architecture is significant for dependency management. Smaller installations can reduce unnecessary dependencies and make it easier to identify which components an application actually uses.</p>



<p class="wp-block-paragraph">However, splitting a library into many packages also increases the importance of compatible version constraints, release coordination, and dependency auditing.</p>



<p class="wp-block-paragraph">PSL also moved from its previous azjezz/psl Composer package to the php-standard-library organization. The original package is marked as abandoned in favor of the new package name.</p>



<p class="wp-block-paragraph">Importantly, the PHP namespace remains Psl, reducing the amount of application source code that must change during a package migration.</p>



<h2 class="wp-block-heading">Type Validation as an Application Boundary</h2>



<p class="wp-block-paragraph">One of PSL&#8217;s strongest use cases is validating untrusted data.</p>



<p class="wp-block-paragraph">Consider a PHP endpoint receiving a JSON request to create a customer account. The application expects a name and an age, but the incoming data may contain missing fields, incorrect types, or unexpected values.</p>



<p class="wp-block-paragraph">Without a structured validation system, developers often write repetitive conditional checks or rely on framework-specific request validation.</p>



<p class="wp-block-paragraph">PSL provides composable type definitions that can validate a structured payload.</p>



<pre class="wp-block-code"><code class="" data-line="">&lt;?php

declare(strict_types=1);

require __DIR__ . &#039;/vendor/autoload.php&#039;;

use Psl\Type;

$customerType = Type\shape(&#091;
    &#039;name&#039; =&gt; Type\non_empty_string(),
    &#039;age&#039; =&gt; Type\positive_int(),
]);

$payload = &#091;
    &#039;name&#039; =&gt; &#039;Alice&#039;,
    &#039;age&#039; =&gt; 32,
];

try {
    $customer = $customerType-&gt;assert(
        $payload
    );

    echo $customer&#091;&#039;name&#039;];
} catch (Type\Exception\AssertException $e) {
    // Convert the validation failure into
    // an appropriate application response.
    error_log($e-&gt;getMessage());
}</code></pre>



<p class="wp-block-paragraph">This example uses PSL&#8217;s documented Type API. It has not been executed as part of this review.</p>



<p class="wp-block-paragraph">The shape definition expresses the expected structure in one place. Invalid data produces a typed exception rather than silently passing through the application.</p>



<p class="wp-block-paragraph">There is still an important distinction between type validation and business validation. A positive integer may be a valid age representation without being acceptable for a particular product or legal requirement.</p>



<p class="wp-block-paragraph">Applications must continue to enforce domain rules, authorization, and database constraints separately.</p>



<h2 class="wp-block-heading">Beyond Collections: Asynchronous PHP</h2>



<p class="wp-block-paragraph">PSL&#8217;s scope extends considerably beyond array and string helpers.</p>



<p class="wp-block-paragraph">The library includes asynchronous execution primitives and components for TCP, TLS, UDP, and other I/O operations.</p>



<p class="wp-block-paragraph">This makes PSL relevant to developers building network services, protocol clients, workers, and applications that perform multiple I/O-bound operations.</p>



<p class="wp-block-paragraph">Its asynchronous model builds on PHP&#8217;s modern execution capabilities and an event-loop dependency, rather than requiring developers to manage every non-blocking operation directly.</p>



<p class="wp-block-paragraph">Version 6 introduced cancellation-token abstractions for controlling asynchronous operations. This is a meaningful design choice because cancellation is not simply an exception that happens after a timeout.</p>



<p class="wp-block-paragraph">Long-running operations may need to respond to explicit cancellation, deadlines, or linked cancellation conditions. Correct cancellation behavior matters for resource cleanup and service reliability.</p>



<p class="wp-block-paragraph">Nevertheless, asynchronous programming is not automatically faster than synchronous PHP.</p>



<p class="wp-block-paragraph">For CPU-intensive operations, introducing an event loop does not remove the underlying computation cost. For applications that perform straightforward database requests and render responses, the additional concurrency model may not be justified.</p>



<p class="wp-block-paragraph">The value depends on workload characteristics, the surrounding architecture, and whether developers can maintain the resulting concurrency behavior safely.</p>



<h2 class="wp-block-heading">Networking and the Importance of Release Maintenance</h2>



<p class="wp-block-paragraph">The latest PSL release at the time of this review is version 6.4.2, published on October 28, 2026.</p>



<p class="wp-block-paragraph">It addresses two Windows-specific networking defects.</p>



<p class="wp-block-paragraph">The first involved failed TLS handshakes that could repeatedly retry socket operations and consume an entire CPU core until cancellation.</p>



<p class="wp-block-paragraph">The second involved peeking at a TCP connection that had been reset by its peer, potentially producing a similar busy-loop condition.</p>



<p class="wp-block-paragraph">The fixes are particularly relevant to applications using PSL&#8217;s TLS connector, HTTP client, SMTP functionality, or TCP components on Windows.</p>



<p class="wp-block-paragraph">These are not merely cosmetic changes. They illustrate how low-level networking libraries can expose platform-specific behavior that is difficult to reproduce through ordinary application tests.</p>



<p class="wp-block-paragraph">They also reinforce the importance of maintaining dependencies and monitoring upstream releases when an application relies on third-party implementations of transport protocols.</p>



<h2 class="wp-block-heading">Security: Strong Primitives Still Need Correct Usage</h2>



<p class="wp-block-paragraph">PSL provides cryptographic utilities, including capabilities built around established PHP extensions such as Sodium.</p>



<p class="wp-block-paragraph">Using well-defined cryptographic primitives can help developers avoid fragile, improvised implementations. However, the availability of encryption or signing functions does not make an application secure by itself.</p>



<p class="wp-block-paragraph">Key generation, storage, rotation, access controls, nonce handling, and protocol design remain essential responsibilities.</p>



<p class="wp-block-paragraph">For networking components, developers must also consider certificate verification, timeouts, cancellation, resource limits, and untrusted remote endpoints.</p>



<p class="wp-block-paragraph">PSL&#8217;s broader functionality creates a corresponding dependency-management obligation. A vulnerability in a low-level protocol implementation may affect several higher-level components.</p>



<p class="wp-block-paragraph">Teams should review Composer security advisories, track the exact installed package versions, and update affected components promptly.</p>



<p class="wp-block-paragraph">For production use, Composer audit checks and platform-specific integration tests are sensible additions to the normal continuous-integration process.</p>



<h2 class="wp-block-heading">Compatibility and Deployment Considerations</h2>



<p class="wp-block-paragraph">PSL 6.4 targets modern PHP environments. Its package metadata declares support for PHP 8.4, PHP 8.5, and PHP 8.6.</p>



<p class="wp-block-paragraph">The complete package also requires several PHP extensions, including bcmath, intl, json, mbstring, openssl, and sodium, together with its event-loop dependency.</p>



<p class="wp-block-paragraph">Installing only the required components may reduce the dependency footprint, although individual packages retain their own platform requirements.</p>



<p class="wp-block-paragraph">PSL is framework-independent. It can be used within Symfony, Laravel, a custom application, or a standalone PHP service, provided the runtime and dependencies are compatible.</p>



<p class="wp-block-paragraph">However, framework independence does not guarantee architectural compatibility. A framework may already provide validation, HTTP clients, collections, or asynchronous abstractions with different conventions.</p>



<p class="wp-block-paragraph">Adopting PSL alongside existing framework components can create overlapping abstractions. Developers should identify which responsibilities PSL will own rather than introducing it everywhere indiscriminately.</p>



<h2 class="wp-block-heading">PSL Versus Native PHP and Framework Utilities</h2>



<p class="wp-block-paragraph">Native PHP functions remain the simplest choice for many applications. They are universally available within compatible runtimes, require no additional Composer dependency, and are familiar to most PHP developers.</p>



<p class="wp-block-paragraph">Framework utilities offer another alternative. Symfony provides components for validation, HTTP communication, serialization, and other concerns. Laravel supplies collections, validation, queues, and a broad application ecosystem.</p>



<p class="wp-block-paragraph">PSL differs by attempting to establish a consistent set of lower-level APIs that can be used across frameworks and standalone applications.</p>



<p class="wp-block-paragraph">This is attractive for teams seeking predictable types and errors without tying utility code to a particular framework.</p>



<p class="wp-block-paragraph">But the benefits must be weighed against additional abstractions, dependency updates, onboarding requirements, and the possibility that native PHP already provides an adequate solution.</p>



<p class="wp-block-paragraph">For a small website performing conventional request-response operations, adopting the complete PSL library would be difficult to justify solely for a handful of string and array functions.</p>



<p class="wp-block-paragraph">For a larger application with extensive data transformation, typed boundaries, and specialized networking requirements, the case becomes more substantial.</p>



<h2 class="wp-block-heading">What We Would Evaluate Before Adoption</h2>



<p class="wp-block-paragraph">A practical evaluation should begin with one application boundary or component rather than an immediate rewrite of existing utility code.</p>



<ul class="wp-block-list">
<li><strong>Type validation:</strong> Compare PSL&#8217;s type definitions with the application&#8217;s existing request-validation approach.</li>



<li><strong>Collections:</strong> Check whether explicit vector and dictionary operations improve readability and reduce accidental key-handling mistakes.</li>



<li><strong>Dependencies:</strong> Measure the difference between installing selected components and the complete library.</li>



<li><strong>Compatibility:</strong> Test the target PHP runtime, required extensions, operating systems, and existing framework integrations.</li>



<li><strong>Failure behavior:</strong> Verify exception handling, cancellation, timeouts, and resource cleanup under realistic failure conditions.</li>



<li><strong>Maintenance:</strong> Assess upgrade frequency, release notes, security advisories, and compatibility with static-analysis tools.</li>
</ul>



<p class="wp-block-paragraph">Performance claims should be tested against representative application workloads. This review does not include independently executed benchmarks.</p>



<h2 class="wp-block-heading">The PHP Magazine Verdict</h2>



<p class="wp-block-paragraph">PSL addresses a real weakness in PHP&#8217;s developer experience: the uneven conventions of a large standard library that has evolved over many years.</p>



<p class="wp-block-paragraph">Its most convincing features are not necessarily the largest ones. Explicit collection operations, composable type validation, and predictable failure behavior can improve application code without requiring a change in framework or deployment model.</p>



<p class="wp-block-paragraph">The move to independently installable packages makes the project more practical for teams that want selected functionality rather than a comprehensive replacement for PHP&#8217;s built-in APIs.</p>



<p class="wp-block-paragraph">At the same time, PSL&#8217;s networking and asynchronous components deserve the scrutiny normally applied to infrastructure libraries. Platform-specific bugs, dependency maintenance, and concurrency semantics become important operational concerns.</p>



<p class="wp-block-paragraph"><strong>PSL is best approached as a collection of deliberate architectural choices, not as a mandatory replacement for native PHP functions.</strong></p>



<p class="wp-block-paragraph">For teams working with modern PHP and seeking stronger type discipline, consistent utility APIs, or specialized asynchronous capabilities, PSL is a project worth evaluating carefully.</p>



<p class="wp-block-paragraph">Its long-term success will depend not only on the breadth of its API, but on maintaining stability, security, and predictable behavior across the platforms developers actually use.</p>



<h2 class="wp-block-heading">Official Sources and Further Reading</h2>



<ul class="wp-block-list">
<li><a href="https://github.com/php-standard-library/php-standard-library">PSL — Official GitHub Repository</a></li>



<li><a href="https://php-standard-library.dev/">PSL — Official Documentation</a></li>



<li><a href="https://github.com/php-standard-library/php-standard-library/releases/tag/6.4.2">PSL 6.4.2 — Release Notes</a></li>



<li><a href="https://packagist.org/packages/php-standard-library/php-standard-library">PSL — Composer Package</a></li>
</ul>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/psl-64-modern-php-standard-library-type-safety-async.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/psl-64-modern-php-standard-library-type-safety-async.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[Long Animation Frames API: Finding the JavaScript Behind Slow Interactions]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/long-animation-frames-api-finding-the-javascript-behind-slow-interactions.html" />

		<id>https://phpmagazine.net/?p=35453</id>
		<updated>2026-11-19T02:37:10Z</updated>
		<published>2026-11-19T12:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="JavaScript" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/long-animation-frames-api-finding-the-javascript-behind-slow-interactions.html"><![CDATA[

<p class="wp-block-paragraph">A dashboard feels sluggish when users open a filter panel. The page loads quickly, network requests complete normally, and the JavaScript bundle is not unusually large. Yet a click sometimes produces a noticeable pause before the interface changes.</p>



<p class="wp-block-paragraph">Knowing that an interaction is slow is only the beginning of the investigation. Developers need to identify which scripts, callbacks and rendering operations contributed to the delay. The Long Animation Frames API, commonly called LoAF, provides detailed information about frames that take more than 50 milliseconds to complete.</p>



<p class="wp-block-paragraph">Unlike a general introduction to Interaction to Next Paint (INP), this article focuses on collecting frame-level evidence and attributing expensive work to specific JavaScript execution paths.</p>



<h2 class="wp-block-heading">Why long tasks are not the whole story</h2>



<p class="wp-block-paragraph">The Long Tasks API identifies tasks that occupy the main thread for more than 50 milliseconds. This is useful for discovering blocking JavaScript execution, but a slow visual update may involve several shorter tasks followed by expensive rendering work.</p>



<p class="wp-block-paragraph">Long Animation Frames examines the frame as a broader unit of work. It can expose time spent before rendering begins, the start of style and layout processing, and attribution for scripts that contributed to the frame.</p>



<p class="wp-block-paragraph">A frame exceeding 50 milliseconds is considered long for this API. That threshold is not the same as an INP quality threshold, and not every long frame corresponds to a user interaction.</p>



<h2 class="wp-block-heading">Collect long frames with PerformanceObserver</h2>



<p class="wp-block-paragraph">The browser exposes LoAF entries through PerformanceObserver using the long-animation-frame entry type. Because support varies by browser, production instrumentation should detect the feature before attempting to observe it.</p>



<pre class="wp-block-code"><code class="" data-line="">if (
  PerformanceObserver.supportedEntryTypes
    .includes(&#039;long-animation-frame&#039;)
) {
  const observer = new PerformanceObserver((list) =&gt; {
    for (const frame of list.getEntries()) {
      console.log({
        start: frame.startTime,
        duration: frame.duration,
        blocking: frame.blockingDuration,
        renderStart: frame.renderStart,
        layoutStart: frame.styleAndLayoutStart
      });
    }
  });

  observer.observe({
    type: &#039;long-animation-frame&#039;,
    buffered: true
  });
}</code></pre>



<p class="wp-block-paragraph">The buffered option allows the observer to receive retained matching entries from before registration, subject to browser buffer limits. For complete session coverage, initialize monitoring early rather than relying on late instrumentation.</p>



<h2 class="wp-block-heading">Understand the frame timeline</h2>



<p class="wp-block-paragraph">A LoAF entry includes startTime and duration, describing the observed frame interval. The renderStart property identifies when rendering-related work begins, including relevant animation-frame callbacks. The styleAndLayoutStart property marks the start of style and layout work.</p>



<p class="wp-block-paragraph">These timestamps help distinguish JavaScript-heavy frames from frames dominated by rendering preparation. They should be interpreted as parts of a timeline rather than independent durations that can simply be added together.</p>



<p class="wp-block-paragraph">The blockingDuration property estimates how much of the frame contributed to blocking responsiveness. It is not equivalent to total frame duration, and it should not be treated as a complete measure of the time required to paint pixels on the screen.</p>



<h2 class="wp-block-heading">Find the scripts responsible</h2>



<p class="wp-block-paragraph">One of LoAF&#8217;s most valuable features is script attribution. A frame can expose a scripts collection containing information about qualifying JavaScript execution, including the source URL, function name, invocation type and execution duration when available.</p>



<pre class="wp-block-code"><code class="" data-line="">const observer = new PerformanceObserver((list) =&gt; {
  for (const frame of list.getEntries()) {
    if (frame.duration &lt; 100) continue;

    const scripts = &#091;...frame.scripts]
      .sort((a, b) =&gt; b.duration - a.duration)
      .slice(0, 5);

    console.table(scripts.map((script) =&gt; ({
      source: script.sourceURL,
      function: script.sourceFunctionName,
      invoker: script.invoker,
      duration: script.duration
    })));
  }
});

if (
  PerformanceObserver.supportedEntryTypes
    .includes(&#039;long-animation-frame&#039;)
) {
  observer.observe({
    type: &#039;long-animation-frame&#039;
  });
}</code></pre>



<p class="wp-block-paragraph">This example prioritizes frames lasting at least 100 milliseconds and lists the longest attributed script executions. It is a diagnostic filter, not a universal performance threshold.</p>



<p class="wp-block-paragraph">Attribution may be incomplete. Browser security restrictions, cross-origin scripts and implementation details can limit the information available. An empty or incomplete scripts collection does not prove that JavaScript played no role.</p>



<h2 class="wp-block-heading">Connect LoAF to a real interaction</h2>



<p class="wp-block-paragraph">Collecting every long frame can generate substantial diagnostic data. A more useful approach is to correlate frame entries with slow interactions and focus on the time intervals that explain poor responsiveness.</p>



<p class="wp-block-paragraph">Google&#8217;s web-vitals attribution tooling can associate LoAF entries with INP diagnostics. Its attribution data can identify the interaction target and provide related long-animation-frame entries, helping engineers move from a slow metric to specific execution evidence.</p>



<p class="wp-block-paragraph">For example, a delayed filter interaction might reveal an expensive event listener in a third-party script. Another interaction might show modest JavaScript execution followed by substantial style and layout work. The appropriate optimization depends on which component dominates.</p>



<h2 class="wp-block-heading">What to do after identifying the cause</h2>



<p class="wp-block-paragraph">If the problem is expensive JavaScript, investigate repeated calculations, large synchronous loops and unnecessary work inside event handlers. Consider reducing work, splitting tasks where appropriate or moving suitable computation to a worker.</p>



<p class="wp-block-paragraph">If rendering dominates, inspect DOM size, style recalculation, layout dependencies and unnecessary updates. A small JavaScript callback can still trigger expensive browser work when it modifies a large or complex document.</p>



<p class="wp-block-paragraph">Third-party scripts deserve separate scrutiny. Analytics, consent management and embedded widgets can contribute to long frames even when the application&#8217;s own code is efficient.</p>



<h2 class="wp-block-heading">Production monitoring requires restraint</h2>



<p class="wp-block-paragraph">LoAF data can be valuable in real-user monitoring, but collecting every frame from every session is rarely necessary. Use sampling, reasonable payload limits and aggregation. Record enough information to identify recurring problems without producing an excessive volume of telemetry.</p>



<p class="wp-block-paragraph">Script URLs and diagnostic metadata may reveal internal application structure or contain sensitive query parameters. Review collected fields before transmitting them, and apply appropriate privacy controls and retention policies.</p>



<h2 class="wp-block-heading">Browser support and fallback diagnostics</h2>



<p class="wp-block-paragraph">LoAF is available in Chromium-based browsers beginning with Chrome 123, but support is not universal across browser engines. Feature detection is therefore essential. Applications should continue functioning normally when the API is unavailable.</p>



<p class="wp-block-paragraph">For unsupported browsers, other performance entries, field metrics and browser profiling tools remain useful. The absence of LoAF instrumentation should not prevent a team from investigating slow interactions.</p>



<h2 class="wp-block-heading">From symptoms to evidence</h2>



<p class="wp-block-paragraph">Performance metrics tell teams where users experience problems. Long Animation Frames adds a more detailed view of what happened inside the browser during a slow frame.</p>



<p class="wp-block-paragraph">By connecting frame timings with script attribution and real interaction data, developers can replace broad guesses with targeted investigations. The objective is not to eliminate every frame longer than 50 milliseconds, but to identify the work that materially affects the responsiveness users experience.</p>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/long-animation-frames-api-finding-the-javascript-behind-slow-interactions.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/long-animation-frames-api-finding-the-javascript-behind-slow-interactions.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[PHP Phar Metadata: Understanding Deserialization Risks in Modern PHP]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/php-phar-metadata-deserialization-security.html" />

		<id>https://phpmagazine.net/?p=35448</id>
		<updated>2026-11-19T02:33:59Z</updated>
		<published>2026-11-19T11:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="Advanced Topics" /><category scheme="https://phpmagazine.net" term="Security" /><category scheme="https://phpmagazine.net" term="Deserialization" /><category scheme="https://phpmagazine.net" term="getMetadata" /><category scheme="https://phpmagazine.net" term="Object Injection" /><category scheme="https://phpmagazine.net" term="Phar" /><category scheme="https://phpmagazine.net" term="PHP" /><category scheme="https://phpmagazine.net" term="PHP Security" /><category scheme="https://phpmagazine.net" term="Secure Coding" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/php-phar-metadata-deserialization-security.html"><![CDATA[

<p class="wp-block-paragraph">PHP archives, commonly known as Phar files, can package application code and other resources into a single distributable file. They are useful for command-line tools and deployment workflows, but their metadata system has a security history that deserves attention.</p>



<p class="wp-block-paragraph">For years, Phar archives were associated with a surprising attack surface: PHP object deserialization could occur when an application accessed an archive through certain filesystem operations. PHP 8.0 changed that behavior substantially. However, the security problem did not disappear entirely. Applications that explicitly deserialize untrusted archive metadata can still expose themselves to dangerous object reconstruction.</p>



<h2 class="wp-block-heading">What Phar metadata contains</h2>



<p class="wp-block-paragraph">A Phar archive contains a manifest describing its contents. The format also supports archive-level metadata and metadata associated with individual files. PHP allows metadata to contain values that can be serialized, including arrays and objects.</p>



<p class="wp-block-paragraph">Serialization converts PHP values into a representation suitable for storage. Deserialization reconstructs those values later. Reconstructing simple scalar values is relatively straightforward, but rebuilding objects can invoke application-defined behavior and interact with classes already loaded into the process.</p>



<h2 class="wp-block-heading">The historical attack surface</h2>



<p class="wp-block-paragraph">Before PHP 8.0, opening a Phar archive could trigger metadata deserialization automatically. This created opportunities for attackers when an application could be influenced into opening an untrusted Phar through a filesystem-related operation.</p>



<p class="wp-block-paragraph">The danger depended on several conditions, including the presence of exploitable application classes and a path through which attacker-controlled archive data could be processed. It was not the case that every Phar archive automatically provided arbitrary code execution.</p>



<p class="wp-block-paragraph">Nevertheless, the combination of implicit deserialization and unexpected filesystem entry points made Phar metadata an important topic in PHP security reviews.</p>



<h2 class="wp-block-heading">What changed in PHP 8.0</h2>



<p class="wp-block-paragraph">PHP 8.0 deferred metadata deserialization until an application explicitly requests it. Opening an archive no longer automatically reconstructs its metadata objects.</p>



<p class="wp-block-paragraph">The Phar::getMetadata() and PharFileInfo::getMetadata() methods also accept deserialization options. These options give developers greater control over the classes that may be reconstructed.</p>



<p class="wp-block-paragraph">This is an important improvement, but developers must distinguish removing an implicit trigger from making all serialized metadata safe. Calling getMetadata() on untrusted content still crosses a deserialization boundary.</p>



<h2 class="wp-block-heading">Reading metadata with class reconstruction disabled</h2>



<p class="wp-block-paragraph">Consider an application that inspects a trusted archive and expects its metadata to contain a simple associative array. It can explicitly disable object reconstruction when retrieving that metadata.</p>



<pre class="wp-block-code"><code class="" data-line="">&lt;?php
declare(strict_types=1);

$archivePath = __DIR__ . &#039;/trusted-tool.phar&#039;;

$archive = new Phar($archivePath);

$metadata = $archive-&gt;getMetadata(&#091;
    &#039;allowed_classes&#039; =&gt; false,
    &#039;max_depth&#039; =&gt; 32,
]);

if (!is_array($metadata)) {
    throw new UnexpectedValueException(
        &#039;Expected array metadata&#039;
    );
}

$name = $metadata&#091;&#039;name&#039;] ?? null;

if (!is_string($name)) {
    throw new UnexpectedValueException(
        &#039;Invalid metadata name&#039;
    );
}

echo $name . PHP_EOL;</code></pre>



<p class="wp-block-paragraph">The allowed_classes option prevents ordinary serialized objects from being reconstructed as their original classes. The max_depth option restricts the depth of nested serialized structures. The application then validates the type and structure of the returned data.</p>



<p class="wp-block-paragraph">These controls reduce exposure, but they are not a general-purpose guarantee that untrusted serialized input is safe. PHP&#8217;s own documentation advises against deserializing untrusted data, regardless of allowed_classes settings.</p>



<h2 class="wp-block-heading">Why object reconstruction is dangerous</h2>



<p class="wp-block-paragraph">PHP supports object lifecycle methods such as __wakeup() and __unserialize(). These methods can run during deserialization and may perform operations beyond restoring ordinary properties.</p>



<p class="wp-block-paragraph">In a vulnerable application, an attacker may attempt to combine existing classes into an unintended sequence of operations. Such sequences are commonly discussed as gadget chains. Their feasibility depends on the available classes and their behavior, rather than on the Phar format alone.</p>



<p class="wp-block-paragraph">A secure design should avoid treating serialized objects from an external archive as ordinary trusted configuration. If metadata is intended to describe a package name, version or entry point, primitive values and explicit schemas are usually sufficient.</p>



<h2 class="wp-block-heading">Archive metadata versus file metadata</h2>



<p class="wp-block-paragraph">Phar::getMetadata() retrieves metadata associated with the archive itself. PharFileInfo::getMetadata() retrieves metadata associated with an individual archive entry.</p>



<p class="wp-block-paragraph">Both operations deserve review when the archive originates outside the application&#8217;s trust boundary. A codebase that restricts archive-level metadata but reads file-level metadata without options may still contain an unsafe deserialization path.</p>



<h2 class="wp-block-heading">Separate archive validation from metadata parsing</h2>



<p class="wp-block-paragraph">Before inspecting an uploaded or externally downloaded archive, establish its origin and intended purpose. File extension checks alone do not establish trust. Applications should apply appropriate size limits, storage isolation and validation before processing archive contents.</p>



<p class="wp-block-paragraph">For software distribution, verify package provenance and integrity through a trusted distribution mechanism. A cryptographic signature or digest is useful only when its verification is tied to a trusted key or expected value.</p>



<p class="wp-block-paragraph">Even a correctly parsed archive should not automatically be executed. Reading metadata, extracting files and executing packaged PHP code are different operations with different security implications.</p>



<h2 class="wp-block-heading">Prefer simpler metadata formats when possible</h2>



<p class="wp-block-paragraph">If an application controls the package format, JSON can be a practical alternative for ordinary metadata. A JSON document can describe names, versions, dependencies and other structured values without reconstructing arbitrary PHP application objects.</p>



<p class="wp-block-paragraph">JSON still requires schema validation, input-size controls and appropriate handling of untrusted values. Its advantage in this context is that decoding a JSON document does not invoke PHP object lifecycle methods from serialized application classes.</p>



<h2 class="wp-block-heading">A focused security review</h2>



<p class="wp-block-paragraph">Teams maintaining older PHP applications should identify their supported runtime versions and search for uses of Phar::getMetadata(), PharFileInfo::getMetadata() and direct unserialize() calls. Each occurrence should be evaluated according to the origin of the data and the classes it may reconstruct.</p>



<p class="wp-block-paragraph">Applications still running PHP 7 require particular attention because their Phar metadata behavior differs from modern PHP versions. Upgrading the runtime is an important security improvement, but it does not remove the need to review explicit deserialization operations.</p>



<p class="wp-block-paragraph">The key lesson is that serialized metadata is not passive text. PHP 8.0 removed an important implicit deserialization behavior, while leaving developers responsible for the trust boundaries around explicit metadata access. Treating those boundaries carefully is essential for secure archive processing.</p>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/php-phar-metadata-deserialization-security.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/php-phar-metadata-deserialization-security.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>PHP Magazine Editors</name>
							<uri>https://phpmagazine.net</uri>
						</author>

		<title type="html"><![CDATA[The Article Was Wrong. What Should a Technical Publisher Do Next?]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/technical-publishing-corrections-policy.html" />

		<id>https://phpmagazine.net/?p=35395</id>
		<updated>2026-11-17T00:43:58Z</updated>
		<published>2026-11-18T20:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="Blogging" /><category scheme="https://phpmagazine.net" term="corrections" /><category scheme="https://phpmagazine.net" term="developer blogs" /><category scheme="https://phpmagazine.net" term="editorial standards" /><category scheme="https://phpmagazine.net" term="reader trust" /><category scheme="https://phpmagazine.net" term="technical publishing" />
		<summary type="html"><![CDATA[A reader tries the command in a tutorial and discovers that an option is missing. Another notices that a security recommendation applies only to an older version of the software. Both contact the publication. The editor now has two jobs: fix the article and decide what readers need to know about the change. Technical publishing [&#8230;]]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/technical-publishing-corrections-policy.html"><![CDATA[

<p class="wp-block-paragraph">A reader tries the command in a tutorial and discovers that an option is missing. Another notices that a security recommendation applies only to an older version of the software. Both contact the publication. The editor now has two jobs: fix the article and decide what readers need to know about the change.</p>



<p class="wp-block-paragraph">Technical publishing makes this decision particularly consequential. A sentence may be quoted in a team discussion, a code example may be copied into a project, and an old article may continue to appear in search results long after publication. An invisible edit can improve the current page while leaving previous readers unaware that its guidance has changed.</p>



<h2 class="wp-block-heading">Start by understanding the error</h2>



<p class="wp-block-paragraph">Not every change calls for the same response. Correcting a misspelled word is different from changing an example that deletes the wrong database records. A correction to a person’s name is different again: it may not affect a technical decision, but it matters to the person identified incorrectly.</p>



<p class="wp-block-paragraph">Before editing, preserve the original wording in the publication’s internal records. Record where the problem appears, who reported it, the evidence available and whether the article has been distributed elsewhere. Then reproduce the issue where practical. For code, record the relevant language, package and operating-system versions rather than assuming that a reader’s result applies to every environment.</p>



<p class="wp-block-paragraph">A reader’s report is a lead, not automatically the full diagnosis. The example may contain an error; the reader may be using a different version; or the article may have omitted an essential assumption. Each finding requires a different correction.</p>



<h2 class="wp-block-heading">Make the change visible when the meaning changes</h2>



<p class="wp-block-paragraph">Routine copy edits generally do not need a public note. A material factual error or a change that affects the reader’s decision usually deserves one. A concise correction can state what was wrong, what has been changed and when the correction was made.</p>



<p class="wp-block-paragraph">For example: “Correction, November 16: An earlier version said the command removed only expired records. The example could remove additional records. The command and explanation have been corrected.” The note tells readers why they should revisit the example without requiring the publication to reproduce an unsafe command.</p>



<p class="wp-block-paragraph">Place the notice where readers are likely to see it. A significant problem in the central recommendation may justify a note near the beginning; a narrow correction can sit near the affected section. Use the actual correction date, and distinguish a correction from an update caused by a later software release.</p>



<h2 class="wp-block-heading">Respond quickly when the risk is immediate</h2>



<p class="wp-block-paragraph">If an example may expose credentials, corrupt data or create another serious problem, do not wait for a polished rewrite before acting. An editor can temporarily remove the example or place a prominent warning while the team verifies a replacement. The warning should say what readers should avoid and, if known, what they should check.</p>



<p class="wp-block-paragraph">Do not publish a speculative fix merely to fill the gap. Test the revised steps in a representative environment, ask a qualified reviewer to inspect the change and state any remaining limitations. If the error may have exposed a real credential, removing it from the page does not by itself invalidate the credential; the responsible owner needs to address that separately.</p>



<h2 class="wp-block-heading">Follow the article beyond your own website</h2>



<p class="wp-block-paragraph">The original page may not be the only copy. Check newsletters, syndicated versions, downloadable examples and social posts when a material error has been distributed through those channels. A partner may need a corrected passage or a request to add a notice. A newsletter cannot be recalled, but a later issue can alert readers to a consequential mistake.</p>



<p class="wp-block-paragraph">Keep a simple internal record: the article URL, the report, the decision, the correction date, the reviewer and any partners contacted. This creates a useful history without turning every typo into an administrative project.</p>



<h2 class="wp-block-heading">Thank the reader and improve the process</h2>



<p class="wp-block-paragraph">Acknowledge useful reports, but ask before naming the person publicly. Someone may want credit; another may prefer to remain anonymous. If the report cannot yet be confirmed, explain what is being checked rather than promising an immediate change.</p>



<p class="wp-block-paragraph">Finally, ask why the error passed through the original process. Was the example tested against the stated version? Did a reviewer have access to the full context? Was the difference between an update and a correction clear? The answer may be a small change to an editorial checklist, not a new layer of bureaucracy.</p>



<p class="wp-block-paragraph">A publication cannot promise that every article will remain perfect. It can promise a reliable response when evidence shows that something needs to change. For readers making technical decisions, that response is part of the value of the publication.</p>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/technical-publishing-corrections-policy.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/technical-publishing-corrections-policy.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[Building a Reservation System: Start Simple, Architect Later]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/building-a-reservation-system-start-simple-architect-later.html" />

		<id>https://phpmagazine.net/?p=35420</id>
		<updated>2026-11-17T02:59:17Z</updated>
		<published>2026-11-18T14:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="PHP Architecture Lab" /><category scheme="https://phpmagazine.net" term="appointment booking" /><category scheme="https://phpmagazine.net" term="PHP Architecture" /><category scheme="https://phpmagazine.net" term="PHP PDO" /><category scheme="https://phpmagazine.net" term="reservation system" /><category scheme="https://phpmagazine.net" term="Software Design" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/building-a-reservation-system-start-simple-architect-later.html"><![CDATA[

<p class="wp-block-paragraph"><strong>PHP Architecture Lab — Episode 01.</strong> A government agency needs an online appointment booking system. Citizens should be able to find an available time slot, select it, and receive a reservation confirmation. The requirements sound straightforward. The architecture is not necessarily so.</p>



<p class="wp-block-paragraph">Should we begin with a framework? Introduce repositories, interfaces, domain events, and queues? Design for thousands of concurrent users before receiving the first booking?</p>



<p class="wp-block-paragraph">In this first installment of PHP Architecture Lab, we will do something deliberately less ambitious: build a small, functioning reservation application using modern PHP, PDO, and SQLite. Then we will examine what this implementation gets right, where it becomes fragile, and which architectural decisions should wait.</p>



<h2 class="wp-block-heading">A Realistic Starting Point</h2>



<p class="wp-block-paragraph">Imagine a public-service office handling appointments for document verification. It has one service counter, works Monday through Friday, and offers appointments lasting 30 minutes between 9:00 a.m. and 5:00 p.m.</p>



<p class="wp-block-paragraph">Our initial application needs four capabilities:</p>



<ul class="wp-block-list">
<li>Generate available appointment times for a selected date.</li>



<li>Exclude appointments that have already been booked.</li>



<li>Store a new reservation in a database.</li>



<li>Reject invalid or duplicate reservations.</li>
</ul>



<p class="wp-block-paragraph">For this lab, we assume one counter, one service type, no payment, and no authentication. Those are intentional simplifications, not promises that a real public-service application could operate without security, privacy controls, accessibility, or identity verification.</p>



<h2 class="wp-block-heading">Choosing the Smallest Useful Architecture</h2>



<p class="wp-block-paragraph">We will use PHP 8.2 or later and PDO with SQLite. SQLite is convenient for a reproducible experiment because the database is a local file. It is not a claim that SQLite is the right deployment choice for a large government booking platform.</p>



<p class="wp-block-paragraph">We can begin with a single entry point containing three distinct responsibilities: database initialization, availability calculation, and booking operations. This makes the implementation easy to inspect. More importantly, we can observe where the responsibilities begin to interfere with one another before extracting abstractions.</p>



<h3 class="wp-block-heading">1. Create the Data Model</h3>



<p class="wp-block-paragraph">Our first database contains only an appointments table. We store the start and end of each appointment as UTC timestamps, along with the resource being reserved, the service code, and a customer name.</p>



<pre class="wp-block-code"><code class="" data-line="">CREATE TABLE IF NOT EXISTS appointments (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    resource_id INTEGER NOT NULL,
    service_code TEXT NOT NULL,
    client_name TEXT NOT NULL,
    starts_at_utc TEXT NOT NULL,
    ends_at_utc TEXT NOT NULL,
    created_at_utc TEXT NOT NULL,
    CHECK (starts_at_utc &lt; ends_at_utc)
);

CREATE UNIQUE INDEX IF NOT EXISTS
    uq_appointment_start
ON appointments(resource_id, starts_at_utc);
</code></pre>



<p class="wp-block-paragraph">The unique index provides a useful first safeguard: two reservations cannot have the same start time at the same counter. It does not protect against partially overlapping appointments with different start times. That distinction will become important when appointment durations become configurable.</p>



<h2 class="wp-block-heading">2. Establish the Database Connection</h2>



<p class="wp-block-paragraph">For the experiment, create <code class="" data-line="">public/index.php</code>. The database will be stored in a writable directory outside the public web root.</p>



<pre class="wp-block-code"><code class="" data-line="">&lt;?php
declare(strict_types=1);

header(&#039;Content-Type: application/json; charset=utf-8&#039;);

$databasePath = dirname(__DIR__) . &#039;/var/lab.sqlite&#039;;

$pdo = new PDO(&#039;sqlite:&#039; . $databasePath);
$pdo-&gt;setAttribute(
    PDO::ATTR_ERRMODE,
    PDO::ERRMODE_EXCEPTION
);
$pdo-&gt;setAttribute(
    PDO::ATTR_DEFAULT_FETCH_MODE,
    PDO::FETCH_ASSOC
);

$pdo-&gt;exec(&#039;PRAGMA busy_timeout = 3000&#039;);
$pdo-&gt;exec(&lt;&lt;&lt;&#039;SQL&#039;
CREATE TABLE IF NOT EXISTS appointments (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    resource_id INTEGER NOT NULL,
    service_code TEXT NOT NULL,
    client_name TEXT NOT NULL,
    starts_at_utc TEXT NOT NULL,
    ends_at_utc TEXT NOT NULL,
    created_at_utc TEXT NOT NULL,
    CHECK (starts_at_utc &lt; ends_at_utc)
)
SQL);

$pdo-&gt;exec(
    &#039;CREATE UNIQUE INDEX IF NOT EXISTS
     uq_appointment_start
     ON appointments(resource_id, starts_at_utc)&#039;
);
</code></pre>



<p class="wp-block-paragraph">In a real deployment, schema changes belong in versioned migrations rather than request-time initialization. Here, the setup remains visible so readers can reproduce the experiment without additional tooling.</p>



<h2 class="wp-block-heading">3. Calculate Available Appointments</h2>



<p class="wp-block-paragraph">Our first scheduling rule is deliberately fixed. One resource is available on weekdays, every 30 minutes, from 09:00 until 17:00. We use UTC throughout this initial experiment to avoid quietly mixing server-local timestamps with database values. A real office&#8217;s local time zone will be introduced explicitly in Episode 02.</p>



<pre class="wp-block-code"><code class="" data-line="">function availableSlots(
    PDO $pdo,
    string $date
): array {
    $tz = new DateTimeZone(&#039;UTC&#039;);

    $day = DateTimeImmutable::createFromFormat(
        &#039;!Y-m-d&#039;,
        $date,
        $tz
    );

    if (!$day || $day-&gt;format(&#039;Y-m-d&#039;) !== $date) {
        throw new InvalidArgumentException(&#039;Invalid date&#039;);
    }

    if ((int) $day-&gt;format(&#039;N&#039;) &gt; 5) {
        return &#091;];
    }

    $start = $day-&gt;setTime(9, 0);
    $closing = $day-&gt;setTime(17, 0);

    $statement = $pdo-&gt;prepare(
        &#039;SELECT starts_at_utc
         FROM appointments
         WHERE resource_id = 1
           AND starts_at_utc &gt;= ?
           AND starts_at_utc &lt; ?&#039;
    );

    $statement-&gt;execute(&#091;
        $day-&gt;format(&#039;Y-m-d H:i:s&#039;),
        $day-&gt;modify(&#039;+1 day&#039;)-&gt;format(&#039;Y-m-d H:i:s&#039;)
    ]);

    $booked = array_fill_keys(
        $statement-&gt;fetchAll(PDO::FETCH_COLUMN),
        true
    );

    $slots = &#091;];

    for (
        $cursor = $start;
        $cursor &lt; $closing;
        $cursor = $cursor-&gt;modify(&#039;+30 minutes&#039;)
    ) {
        $key = $cursor-&gt;format(&#039;Y-m-d H:i:s&#039;);

        if (
            !isset($booked&#091;$key])
            &amp;&amp; $cursor &gt; new DateTimeImmutable(&#039;now&#039;, $tz)
        ) {
            $slots&#091;] = $cursor-&gt;format(DATE_ATOM);
        }
    }

    return $slots;
}
</code></pre>



<p class="wp-block-paragraph">The algorithm has three steps: generate all possible start times, read the already-booked start times, and remove any collisions. For a single counter and fixed 30-minute appointments, it is understandable and sufficient for the first experiment.</p>



<p class="wp-block-paragraph">It also exposes an important assumption: an appointment occupies exactly one generated slot. Once services have different durations, the relationship between a start time and the occupied interval becomes more complicated.</p>



<h2 class="wp-block-heading">4. Implement the Booking Operation</h2>



<p class="wp-block-paragraph">A booking request should never be trusted simply because the frontend displayed a time as available. The server must validate the requested value again.</p>



<pre class="wp-block-code"><code class="" data-line="">function bookAppointment(
    PDO $pdo,
    string $date,
    string $startTime,
    string $clientName
): int {
    $clientName = trim($clientName);

    if (
        $clientName === &#039;&#039;
        || mb_strlen($clientName) &gt; 120
    ) {
        throw new InvalidArgumentException(
            &#039;Invalid client name&#039;
        );
    }

    $available = availableSlots($pdo, $date);

    if (!in_array($startTime, $available, true)) {
        throw new DomainException(
            &#039;The requested slot is unavailable&#039;
        );
    }

    $start = new DateTimeImmutable($startTime);
    $end = $start-&gt;modify(&#039;+30 minutes&#039;);
    $utc = new DateTimeZone(&#039;UTC&#039;);

    $statement = $pdo-&gt;prepare(
        &#039;INSERT INTO appointments (
            resource_id,
            service_code,
            client_name,
            starts_at_utc,
            ends_at_utc,
            created_at_utc
         ) VALUES (?, ?, ?, ?, ?, ?)&#039;
    );

    try {
        $statement-&gt;execute(&#091;
            1,
            &#039;DOCUMENT_CHECK&#039;,
            $clientName,
            $start-&gt;setTimezone($utc)
                  -&gt;format(&#039;Y-m-d H:i:s&#039;),
            $end-&gt;setTimezone($utc)
                -&gt;format(&#039;Y-m-d H:i:s&#039;),
            (new DateTimeImmutable(&#039;now&#039;, $utc))
                -&gt;format(&#039;Y-m-d H:i:s&#039;)
        ]);
    } catch (PDOException $exception) {
        if (
            ($exception-&gt;errorInfo&#091;1] ?? null) === 19
        ) {
            throw new DomainException(
                &#039;The slot has just been reserved&#039;,
                0,
                $exception
            );
        }

        throw $exception;
    }

    return (int) $pdo-&gt;lastInsertId();
}
</code></pre>



<p class="wp-block-paragraph">Notice the use of prepared statements. Reservation values are passed as parameters rather than interpolated into SQL. Also notice that the unique index is essential: two requests might both read an available slot, but the database will reject a second insertion with an identical start time.</p>



<p class="wp-block-paragraph">This safeguard is narrower than a complete concurrency strategy. It handles identical start times in our simplified model, not arbitrary overlaps or future multi-step workflows.</p>



<h2 class="wp-block-heading">5. Expose a Small HTTP Interface</h2>



<p class="wp-block-paragraph">We can finish the prototype with two endpoints: <code class="" data-line="">GET /availability?date=YYYY-MM-DD</code> and <code class="" data-line="">POST /book</code>. Append this small router after the previous PHP functions.</p>



<pre class="wp-block-code"><code class="" data-line="">$path = parse_url(
    $_SERVER&#091;&#039;REQUEST_URI&#039;],
    PHP_URL_PATH
);

$method = $_SERVER&#091;&#039;REQUEST_METHOD&#039;];

try {
    if ($method === &#039;GET&#039; &amp;&amp; $path === &#039;/availability&#039;) {
        echo json_encode(&#091;
            &#039;slots&#039; =&gt; availableSlots(
                $pdo,
                (string) ($_GET&#091;&#039;date&#039;] ?? &#039;&#039;)
            )
        ], JSON_THROW_ON_ERROR);
        exit;
    }

    if ($method === &#039;POST&#039; &amp;&amp; $path === &#039;/book&#039;) {
        $data = json_decode(
            file_get_contents(&#039;php://input&#039;),
            true,
            512,
            JSON_THROW_ON_ERROR
        );

        if (!is_array($data)) {
            throw new InvalidArgumentException(
                &#039;Expected a JSON object&#039;
            );
        }

        $id = bookAppointment(
            $pdo,
            (string) ($data&#091;&#039;date&#039;] ?? &#039;&#039;),
            (string) ($data&#091;&#039;start&#039;] ?? &#039;&#039;),
            (string) ($data&#091;&#039;client_name&#039;] ?? &#039;&#039;)
        );

        http_response_code(201);

        echo json_encode(&#091;
            &#039;booking_id&#039; =&gt; $id,
            &#039;status&#039; =&gt; &#039;confirmed&#039;
        ], JSON_THROW_ON_ERROR);
        exit;
    }

    http_response_code(404);
    echo json_encode(&#091;&#039;error&#039; =&gt; &#039;Not found&#039;]);
} catch (
    InvalidArgumentException | JsonException $exception
) {
    http_response_code(400);
    echo json_encode(&#091;&#039;error&#039; =&gt; &#039;Invalid request&#039;]);
} catch (DomainException $exception) {
    http_response_code(409);
    echo json_encode(&#091;&#039;error&#039; =&gt; $exception-&gt;getMessage()]);
} catch (Throwable $exception) {
    error_log($exception-&gt;getMessage());
    http_response_code(500);
    echo json_encode(&#091;&#039;error&#039; =&gt; &#039;Internal server error&#039;]);
}
</code></pre>



<p class="wp-block-paragraph">Start the application after creating its writable database directory:</p>



<pre class="wp-block-code"><code class="" data-line="">mkdir -p public var
php -S 127.0.0.1:8000 -t public public/index.php
</code></pre>



<p class="wp-block-paragraph">The native PHP server is for local development only. This example deliberately omits authentication, rate limiting, audit logging, personal-data retention controls, and production configuration. Do not expose it directly as a public booking service.</p>



<h2 class="wp-block-heading">6. Test the First Reservation</h2>



<p class="wp-block-paragraph">First, request the availability for an upcoming weekday:</p>



<pre class="wp-block-code"><code class="" data-line="">curl &quot;http://127.0.0.1:8000/availability?date=2026-11-23&quot;
</code></pre>



<p class="wp-block-paragraph">The response contains a JSON array of available UTC appointment start times. Select one and submit it:</p>



<pre class="wp-block-code"><code class="" data-line="">curl -X POST http://127.0.0.1:8000/book \
  -H &quot;Content-Type: application/json&quot; \
  -d &#039;{
    &quot;date&quot;: &quot;2026-11-23&quot;,
    &quot;start&quot;: &quot;2026-11-23T10:00:00+00:00&quot;,
    &quot;client_name&quot;: &quot;Alex Martin&quot;
  }&#039;
</code></pre>



<p class="wp-block-paragraph">A successful request returns an HTTP 201 response with a booking identifier. A second attempt for the same slot should be rejected.</p>



<h2 class="wp-block-heading">7. What Have We Actually Built?</h2>



<p class="wp-block-paragraph">We now have a small application capable of listing availability, accepting reservations, storing data, and detecting duplicate start times. It has a clear and useful data model. It also has limitations that should shape our next decisions.</p>



<ul class="wp-block-list">
<li><strong>Scheduling is hard-coded.</strong> Hours, weekdays, appointment duration, and the service counter are embedded in PHP functions.</li>



<li><strong>Responsibilities are mixed.</strong> HTTP handling, business rules, and SQL live in one file.</li>



<li><strong>Conflict detection is incomplete.</strong> Reservations with different start times may overlap once durations vary.</li>



<li><strong>The operational model is incomplete.</strong> There is no authentication, cancellation, audit trail, or administrative configuration.</li>



<li><strong>Time-zone policy is simplified.</strong> Real office scheduling needs explicit local-time and daylight-saving rules.</li>
</ul>



<p class="wp-block-paragraph">These are not reasons to immediately introduce a microservices architecture or a dozen interfaces. They are reasons to investigate the application before making larger commitments.</p>



<h2 class="wp-block-heading">The Architectural Decision: What Not to Build Yet</h2>



<p class="wp-block-paragraph">A common architectural mistake is treating future possibilities as current requirements. Our system might eventually require multiple offices, external payment providers, dozens of service types, and significant traffic. But building all those capabilities now would make the first iteration more difficult to understand and test.</p>



<p class="wp-block-paragraph">The better question is not &#8220;Which architecture is most sophisticated?&#8221; It is &#8220;Which decisions can we postpone without creating unacceptable risk?&#8221;</p>



<p class="wp-block-paragraph">We can postpone distributed messaging, multiple deployment services, and generic repository abstractions. We should not postpone basic data validation, database integrity, or a deliberate approach to time representation.</p>



<h2 class="wp-block-heading">Next in PHP Architecture Lab</h2>



<p class="wp-block-paragraph">The next requirement will change the problem considerably. Different public services will need different appointment durations. Offices will close on statutory holidays. Administrators will define opening hours and exceptions.</p>



<p class="wp-block-paragraph">Our fixed 30-minute slot generator will no longer be adequate. In Episode 02, we will introduce a scheduling domain and examine how business rules can be separated from HTTP and persistence without overengineering the application.</p>



<p class="wp-block-paragraph"><strong>PHP Architecture Lab — One application. Real decisions. Better architecture.</strong></p>



<h3 class="wp-block-heading">References</h3>



<ul class="wp-block-list">
<li><a href="https://www.php.net/manual/en/book.pdo.php">PHP Manual — PHP Data Objects (PDO)</a></li>



<li><a href="https://www.php.net/manual/en/pdo.prepared-statements.php">PHP Manual — Prepared Statements</a></li>



<li><a href="https://www.php.net/manual/en/pdo.transactions.php">PHP Manual — Transactions and Auto-Commit</a></li>



<li><a href="https://www.sqlite.org/lang_createindex.html">SQLite Documentation — CREATE INDEX</a></li>
</ul>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/building-a-reservation-system-start-simple-architect-later.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/building-a-reservation-system-start-simple-architect-later.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>PHP Magazine Editors</name>
							<uri>https://phpmagazine.net</uri>
						</author>

		<title type="html"><![CDATA[LibreSign: Bringing Self-Hosted Digital Signatures to PHP and Nextcloud]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/libresign-self-hosted-digital-signatures-nextcloud-php.html" />

		<id>https://phpmagazine.net/?p=35406</id>
		<updated>2026-11-17T01:10:31Z</updated>
		<published>2026-11-18T12:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="PHP Project Radar" /><category scheme="https://phpmagazine.net" term="Digital Signatures" /><category scheme="https://phpmagazine.net" term="document management" /><category scheme="https://phpmagazine.net" term="Electronic Signatures" /><category scheme="https://phpmagazine.net" term="LibreSign" /><category scheme="https://phpmagazine.net" term="Nextcloud" /><category scheme="https://phpmagazine.net" term="Open source" /><category scheme="https://phpmagazine.net" term="PDF" /><category scheme="https://phpmagazine.net" term="PHP" /><category scheme="https://phpmagazine.net" term="PHP Projects Radar" /><category scheme="https://phpmagazine.net" term="PKI" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/libresign-self-hosted-digital-signatures-nextcloud-php.html"><![CDATA[

<p class="wp-block-paragraph">Electronic signatures have become part of everyday business operations. Contracts, purchase orders, employee documents, administrative approvals, and legal records increasingly move through digital signing workflows rather than traditional paper processes.</p>



<p class="wp-block-paragraph">For organizations, the challenge is not simply allowing someone to draw a signature on a document. A complete signing process may involve verifying the signer&#8217;s identity, coordinating several approvals, preserving the final document, validating its cryptographic integrity, and maintaining evidence of what happened.</p>



<p class="wp-block-paragraph">Commercial services such as DocuSign and Adobe Acrobat Sign provide established solutions. However, organizations that prefer to operate their own infrastructure may want greater control over document storage, signing policies, and integration with existing business systems.</p>



<p class="wp-block-paragraph"><strong>LibreSign is an open-source electronic signature application built for Nextcloud. It enables organizations to request, sign, track, and validate documents while retaining control over the infrastructure running the signing service.</strong></p>



<p class="wp-block-paragraph">Developed by LibreCode Coop and contributors, LibreSign is distributed under the AGPL-3.0-or-later license. The project has been publicly developed since 2020 and was recognized as a Digital Public Good in 2025.</p>



<p class="wp-block-paragraph">For this edition of PHP Projects Radar, we examine LibreSign&#8217;s architecture, its integration capabilities, the distinction between electronic and cryptographic signatures, and the operational responsibilities involved in running a signing service.</p>



<h2 class="wp-block-heading">More Than Adding a Signature to a PDF</h2>



<p class="wp-block-paragraph">A visual signature and a digital signature are not necessarily the same thing.</p>



<p class="wp-block-paragraph">Adding an image of someone&#8217;s handwritten signature to a PDF may communicate an intention to sign, but the image alone does not establish cryptographic integrity or provide reliable evidence of the signer&#8217;s identity.</p>



<p class="wp-block-paragraph">A cryptographic digital signature can bind a document to a signing certificate, making unauthorized modifications detectable through signature validation.</p>



<p class="wp-block-paragraph">However, even a technically valid digital signature requires additional considerations. Who controlled the signing credential? How was the signer identified? Was the certificate trusted? What evidence connects the signature to the relevant individual or organization?</p>



<p class="wp-block-paragraph">LibreSign addresses these concerns through a combination of signing workflows, identity methods, certificate infrastructure, validation tools, and document traceability.</p>



<p class="wp-block-paragraph">It should not be assumed that every LibreSign deployment automatically meets every legal standard. Compliance depends on the selected signing method, certificate trust, identity verification, operational procedures, and applicable legislation.</p>



<h2 class="wp-block-heading">LibreSign Is a Nextcloud Application</h2>



<p class="wp-block-paragraph">An important architectural distinction is that LibreSign is not a standalone PHP framework or a Composer library that can be added directly to an arbitrary application.</p>



<p class="wp-block-paragraph">It runs as an application within a compatible Nextcloud installation.</p>



<p class="wp-block-paragraph">This allows LibreSign to work with Nextcloud&#8217;s existing users, files, permissions, and application infrastructure. Documents can remain within the organization&#8217;s file-management environment rather than being transferred to an unrelated hosted signing platform.</p>



<p class="wp-block-paragraph">The backend is implemented in PHP using Nextcloud&#8217;s application interfaces. Its source structure separates HTTP controllers, services, persistence components, and specialized signing and certificate handlers.</p>



<p class="wp-block-paragraph">The frontend uses Vue and TypeScript to provide interfaces for requesting signatures, managing recipients, inspecting document status, and performing signing operations.</p>



<p class="wp-block-paragraph">From an architectural perspective, LibreSign combines a conventional PHP application backend with specialized cryptographic services and a workflow-oriented user interface.</p>



<h2 class="wp-block-heading">A Practical Scenario: Signing a Supplier Agreement</h2>



<p class="wp-block-paragraph">Consider a small organization that needs to approve agreements with external suppliers.</p>



<p class="wp-block-paragraph">The existing process may involve emailing PDF documents, collecting signatures manually, checking whether every participant responded, and storing signed copies in a shared folder.</p>



<p class="wp-block-paragraph">With LibreSign, an authorized employee can prepare a signing request using a document uploaded to Nextcloud or selected from an existing file.</p>



<p class="wp-block-paragraph">The employee can select recipients, define supported identification methods, and configure signing order according to the organization&#8217;s workflow.</p>



<p class="wp-block-paragraph">Recipients may include both internal users and external signers. External participation depends on the identification and invitation methods enabled by the administrator.</p>



<p class="wp-block-paragraph">The application tracks which signers are pending and which have completed their part. A document is not considered fully signed merely because one participant has approved it.</p>



<p class="wp-block-paragraph">Once the required signing process is complete, the resulting PDF can be inspected and validated using the available certificate and signature information.</p>



<p class="wp-block-paragraph">This provides a structured alternative to coordinating signatures through ordinary email attachments.</p>



<h2 class="wp-block-heading">Installation and Initial Configuration</h2>



<p class="wp-block-paragraph">LibreSign is available from the official Nextcloud App Store.</p>



<p class="wp-block-paragraph">At the time of this review, LibreSign 15.0.12 is the latest stable version documented for Nextcloud 35. Version compatibility is important: LibreSign and Nextcloud use different release numbering, and administrators must select the application version appropriate for their installed Nextcloud release.</p>



<p class="wp-block-paragraph">Installation begins in Nextcloud&#8217;s application administration interface. After enabling LibreSign, administrators must complete the application&#8217;s configuration checks.</p>



<p class="wp-block-paragraph">Depending on the selected signing backend, this may involve installing supporting binaries, validating cryptographic dependencies, and configuring certificate information.</p>



<p class="wp-block-paragraph">The application&#8217;s administrative documentation specifically warns against regenerating an existing production root certificate as a routine troubleshooting measure.</p>



<p class="wp-block-paragraph">Signing keys and certificate material are not disposable configuration values. Losing or replacing them without a migration and recovery plan can affect the ability to validate previously signed documents.</p>



<p class="wp-block-paragraph">Before production use, administrators should complete a signing test and verify the resulting PDF using the application&#8217;s validation tools.</p>



<h2 class="wp-block-heading">Integrating LibreSign with Existing PHP Applications</h2>



<p class="wp-block-paragraph">One of LibreSign&#8217;s most interesting capabilities for PHP developers is its application programming interface.</p>



<p class="wp-block-paragraph">Organizations do not necessarily need to replace an existing customer portal, ERP system, or administrative application to introduce document signing.</p>



<p class="wp-block-paragraph">A PHP application can communicate with LibreSign through its documented API, initiating authorized signing workflows and retrieving their status.</p>



<p class="wp-block-paragraph">LibreSign exposes endpoints through Nextcloud&#8217;s Open Collaboration Services, or OCS, interface. API responses use a JSON structure containing an OCS metadata section and application data.</p>



<p class="wp-block-paragraph">The following example demonstrates a read-only integration that retrieves signing requests accessible to an authorized Nextcloud account.</p>



<p class="wp-block-paragraph">The endpoint and response structure are documented for LibreSign 15.0.12. The example requires the PHP cURL extension, an HTTPS Nextcloud installation, and an account authorized to access the requested records.</p>



<pre class="wp-block-code"><code class="" data-line="">&lt;?php

declare(strict_types=1);

$base = rtrim(
    (string) getenv(&#039;NEXTCLOUD_URL&#039;),
    &#039;/&#039;
);

$user = (string) getenv(&#039;NEXTCLOUD_USER&#039;);

$password = (string) getenv(
    &#039;NEXTCLOUD_APP_PASSWORD&#039;
);

if (
    !str_starts_with($base, &#039;https://&#039;)
    || $user === &#039;&#039;
    || $password === &#039;&#039;
) {
    throw new RuntimeException(
        &#039;Missing secure Nextcloud configuration&#039;
    );
}

$url = $base
    . &#039;/ocs/v2.php/apps/libresign/api/v1&#039;
    . &#039;/file/list?details=1&#039;;

$handle = curl_init($url);

if ($handle === false) {
    throw new RuntimeException(
        &#039;Cannot initialize cURL&#039;
    );
}

try {
    curl_setopt_array($handle, &#091;
        CURLOPT_RETURNTRANSFER =&gt; true,
        CURLOPT_HTTPAUTH =&gt; CURLAUTH_BASIC,
        CURLOPT_USERPWD =&gt;
            $user . &#039;:&#039; . $password,
        CURLOPT_HTTPHEADER =&gt; &#091;
            &#039;OCS-APIRequest: true&#039;,
            &#039;Accept: application/json&#039;,
        ],
        CURLOPT_TIMEOUT =&gt; 20,
        CURLOPT_FOLLOWLOCATION =&gt; false,
    ]);

    $body = curl_exec($handle);

    $httpCode = (int) curl_getinfo(
        $handle,
        CURLINFO_HTTP_CODE
    );

    if (
        !is_string($body)
        || $httpCode !== 200
    ) {
        throw new RuntimeException(
            &#039;LibreSign API request failed&#039;
        );
    }
} finally {
    curl_close($handle);
}

$response = json_decode(
    $body,
    true,
    512,
    JSON_THROW_ON_ERROR
);

$ocs = $response&#091;&#039;ocs&#039;] ?? null;

$records = $ocs&#091;&#039;data&#039;]&#091;&#039;data&#039;] ?? null;

if (
    !is_array($records)
    || !array_is_list($records)
) {
    throw new RuntimeException(
        &#039;Unexpected LibreSign response structure&#039;
    );
}

foreach ($records as $record) {
    printf(
        &quot;%s | %s\n&quot;,
        (string) ($record&#091;&#039;uuid&#039;] ?? &#039;unknown&#039;),
        (string) (
            $record&#091;&#039;statusText&#039;] ?? &#039;unknown&#039;
        )
    );
}</code></pre>



<p class="wp-block-paragraph">This example deliberately performs no signing operation and does not modify documents.</p>



<p class="wp-block-paragraph">For a production integration, the application should use a dedicated account with appropriately restricted permissions, store credentials securely, and handle API errors without exposing tokens or document information in logs.</p>



<p class="wp-block-paragraph">The complete LibreSign API also exposes operations for requesting signatures and validating documents. Developers should use the version-specific OpenAPI contract rather than assuming that endpoints or payloads from an unreleased development version are compatible with their installation.</p>



<h2 class="wp-block-heading">The Cryptographic Infrastructure Behind Signatures</h2>



<p class="wp-block-paragraph">Digital signature applications introduce responsibilities that ordinary document-management systems do not necessarily have.</p>



<p class="wp-block-paragraph">A valid cryptographic signature depends on the integrity of the signed content, access to signing credentials, appropriate certificate handling, and the ability to evaluate the relevant trust chain.</p>



<p class="wp-block-paragraph">LibreSign supports certificate-based signing workflows and provides administrative configuration for its signing engine and certificate infrastructure.</p>



<p class="wp-block-paragraph">Depending on the deployment&#8217;s requirements, administrators may also need to consider certificate revocation information, timestamping services, trust anchors, and long-term validation evidence.</p>



<p class="wp-block-paragraph">These details matter because the ability to display a signature in a PDF is not equivalent to establishing that the signature remains trustworthy years later.</p>



<p class="wp-block-paragraph">Organizations maintaining signed records over long retention periods should establish clear policies for certificates, backups, evidence preservation, and verification after software upgrades.</p>



<h2 class="wp-block-heading">Electronic Signatures and Legal Compliance</h2>



<p class="wp-block-paragraph">Legal compliance deserves separate attention from the software&#8217;s technical capabilities.</p>



<p class="wp-block-paragraph">In the European Union, the eIDAS framework distinguishes different levels of electronic signatures, including advanced and qualified electronic signatures.</p>



<p class="wp-block-paragraph">Other jurisdictions, including Canada and the United States, have their own rules concerning electronic signatures, identity, consent, record integrity, and the types of documents that may be signed electronically.</p>



<p class="wp-block-paragraph">A signature produced using cryptographic technology does not automatically qualify for the highest legal classification in every jurisdiction.</p>



<p class="wp-block-paragraph">For example, qualified electronic signatures in the European regulatory context depend on specific trust-service and certificate requirements, not merely the availability of a PDF-signing library.</p>



<p class="wp-block-paragraph">Organizations should therefore validate the legal and procedural requirements of their intended use cases before treating an installation as a legally sufficient signing solution.</p>



<p class="wp-block-paragraph">LibreSign&#8217;s validation functionality helps inspect technical signature evidence. It cannot independently decide every legal question associated with a document or signing process.</p>



<h2 class="wp-block-heading">Security and Operational Responsibilities</h2>



<p class="wp-block-paragraph">Self-hosting gives organizations greater operational control, but it also transfers responsibilities that would otherwise be handled by a managed service provider.</p>



<p class="wp-block-paragraph">The Nextcloud server must be maintained, patched, monitored, and backed up. The LibreSign application must remain compatible with the installed Nextcloud release.</p>



<p class="wp-block-paragraph">HTTPS, correct reverse-proxy configuration, controlled access to documents, and reliable background jobs are important production requirements.</p>



<p class="wp-block-paragraph">Signing credentials and certificate material require particularly careful protection. Backups must include the information necessary to restore the service without compromising private keys.</p>



<p class="wp-block-paragraph">Administrators should also test whether unauthorized accounts can access other users&#8217; requests or signed documents, and whether external invitation links can be misused.</p>



<p class="wp-block-paragraph">Because signing workflows may involve sensitive personal information, organizations must establish retention, access-control, and incident-response policies appropriate to their environment.</p>



<h2 class="wp-block-heading">How LibreSign Compares with Commercial Services</h2>



<p class="wp-block-paragraph">LibreSign&#8217;s principal attraction is not that it reproduces every feature offered by commercial electronic-signature platforms.</p>



<p class="wp-block-paragraph">Its distinguishing feature is the ability to operate an open-source signing application within an existing Nextcloud environment.</p>



<p class="wp-block-paragraph">Commercial services such as DocuSign and Adobe Acrobat Sign provide managed infrastructure, extensive integrations, and commercial support options. Their feature sets, legal-service arrangements, and pricing vary by product and plan.</p>



<p class="wp-block-paragraph">LibreSign places greater responsibility for deployment, certificate configuration, availability, and long-term maintenance on the organization operating the service.</p>



<p class="wp-block-paragraph">For teams already running Nextcloud, this may be an acceptable trade-off. For organizations without experience maintaining secure PHP applications and certificate infrastructure, operational complexity may outweigh the benefits of self-hosting.</p>



<p class="wp-block-paragraph">LibreSign&#8217;s software and API are available under an open-source license without a software licensing fee. Optional professional deployment, integration, and support services are offered separately.</p>



<p class="wp-block-paragraph">That makes the financial evaluation broader than a comparison of subscription prices. Infrastructure, security administration, support, integration, and maintenance must also be considered.</p>



<h2 class="wp-block-heading">What We Would Test Before Production Adoption</h2>



<p class="wp-block-paragraph">A meaningful evaluation should begin with a complete signing workflow rather than a demonstration showing only that a PDF can be signed.</p>



<ul class="wp-block-list">
<li><strong>Identity:</strong> Confirm how internal and external signers are identified, and test whether one recipient can access another recipient&#8217;s signing invitation.</li>



<li><strong>Workflow:</strong> Test parallel and sequential signatures, declined requests, expired invitations, and partially completed documents.</li>



<li><strong>Cryptography:</strong> Validate completed PDFs, certificate status, trust-chain behavior, and the detection of modifications.</li>



<li><strong>Integration:</strong> Verify API authentication, authorized document retrieval, error responses, and handling of repeated notifications.</li>



<li><strong>Recovery:</strong> Restore a backup in an isolated environment and confirm that signed documents and required certificate material remain accessible.</li>



<li><strong>Compliance:</strong> Have the applicable signature policy reviewed against the legal requirements of the documents and jurisdictions involved.</li>
</ul>



<p class="wp-block-paragraph">These tests are particularly important for organizations introducing LibreSign into financial, legal, public-sector, or human-resources workflows.</p>



<h2 class="wp-block-heading">The PHP Magazine Verdict</h2>



<p class="wp-block-paragraph">LibreSign addresses a meaningful requirement in the open-source business application ecosystem: managing document-signing workflows without depending entirely on a hosted commercial service.</p>



<p class="wp-block-paragraph">Its integration with Nextcloud provides a practical foundation for organizations already managing users and documents on that platform. The availability of an API extends its usefulness to existing PHP applications and business portals.</p>



<p class="wp-block-paragraph">The project also demonstrates that electronic signatures require more than a PDF library. Identity verification, certificate management, process state, validation, access control, and long-term evidence are equally important components of the system.</p>



<p class="wp-block-paragraph">Nevertheless, LibreSign is not a drop-in replacement for every commercial electronic-signature service. Its Nextcloud dependency, cryptographic configuration, legal considerations, and operational requirements must be evaluated carefully.</p>



<p class="wp-block-paragraph"><strong>LibreSign is most compelling for organizations that already operate Nextcloud and want to incorporate document signing into their own infrastructure and business processes.</strong></p>



<p class="wp-block-paragraph">For PHP developers, the project is also worth examining as an example of how application workflows, document management, and cryptographic services can be combined into a reusable open-source system.</p>



<h2 class="wp-block-heading">Official Sources and Further Reading</h2>



<ul class="wp-block-list">
<li><a href="https://github.com/LibreSign/libresign">LibreSign — Official GitHub Repository</a></li>



<li><a href="https://apps.nextcloud.com/apps/libresign">LibreSign — Nextcloud App Store</a></li>



<li><a href="https://docs.libresign.coop/15/">LibreSign 15 — Official Documentation</a></li>



<li><a href="https://docs.libresign.coop/15/developer_manual/api/openapi.html">LibreSign 15 — Versioned API Reference</a></li>
</ul>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/libresign-self-hosted-digital-signatures-nextcloud-php.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/libresign-self-hosted-digital-signatures-nextcloud-php.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[Browser-Side Concurrency: Web Locks, IndexedDB, and the Architecture of Reliable Offline Synchronization]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/browser-concurrency-web-locks-indexeddb-offline-sync.html" />

		<id>https://phpmagazine.net/?p=35386</id>
		<updated>2026-11-17T00:19:18Z</updated>
		<published>2026-11-18T11:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="Front-End Best Practices" /><category scheme="https://phpmagazine.net" term="Background Sync" /><category scheme="https://phpmagazine.net" term="Browser Concurrency" /><category scheme="https://phpmagazine.net" term="Distributed Systems" /><category scheme="https://phpmagazine.net" term="Idempotency" /><category scheme="https://phpmagazine.net" term="IndexedDB" /><category scheme="https://phpmagazine.net" term="javascript" /><category scheme="https://phpmagazine.net" term="Offline First" /><category scheme="https://phpmagazine.net" term="Service Workers" /><category scheme="https://phpmagazine.net" term="Web Locks API" />
		<summary type="html"><![CDATA[]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/browser-concurrency-web-locks-indexeddb-offline-sync.html"><![CDATA[

<p class="wp-block-paragraph">An offline-capable web application is not simply a website that continues displaying cached pages without an internet connection. Once users can create or modify business data while disconnected, the browser becomes a temporary data-processing environment with its own concurrency, persistence and recovery problems.</p>



<p class="wp-block-paragraph">Consider a field-service application used by technicians. A technician opens a work order, records an inspection, adds notes and marks a task complete. Connectivity disappears before the changes reach the server. The application must preserve the work locally and synchronize it later, potentially while several tabs are open.</p>



<p class="wp-block-paragraph">What happens if two tabs attempt synchronization simultaneously? What if the server accepts an operation but the browser never receives the response? What if a technician edits a record that another employee has already changed?</p>



<p class="wp-block-paragraph">These problems require more than a service worker and a cache. They require an explicit consistency model.</p>



<h2 class="wp-block-heading">The browser is a concurrent application environment</h2>



<p class="wp-block-paragraph">Modern browser applications can execute code in multiple tabs, dedicated workers and service workers. These contexts can access origin-scoped storage and initiate network requests independently.</p>



<p class="wp-block-paragraph">A JavaScript variable in one tab does not coordinate activity in another. Likewise, a localStorage flag is not a reliable distributed mutex: reading a value and updating it are separate operations that can race.</p>



<p class="wp-block-paragraph">The Web Locks API addresses this coordination problem. It allows cooperating execution contexts to request named locks, with the browser managing access. Exclusive locks prevent another cooperating context from holding the same lock concurrently.</p>



<p class="wp-block-paragraph">But the first architectural decision is to identify what actually requires coordination. Ordinary IndexedDB writes already have transactional guarantees. Web Locks is useful when a workflow spans several independent operations, such as reading a local queue, sending an HTTP request and recording the result.<br><br><img decoding="async" src="https://phpmagazine.net/wp-content/uploads/2026/11/conceptual_architecture-1010x1024.png" alt=""></p>



<h2 class="wp-block-heading">Start with an outbox, not a network request</h2>



<p class="wp-block-paragraph">An offline-first design should not depend on a network request succeeding when the user presses Save.</p>



<p class="wp-block-paragraph">Instead, the application records a durable local operation in an outbox. Each operation receives a stable identifier that will also serve as its server-side idempotency key.</p>



<p class="wp-block-paragraph">For example, completing an inspection might produce this record:</p>



<pre class="wp-block-code"><code class="" data-line="">{
  &quot;id&quot;: &quot;2f6e9e0e-76e0-46db-b90b-40dc60f4d9b2&quot;,
  &quot;type&quot;: &quot;inspection.completed&quot;,
  &quot;entityId&quot;: &quot;inspection-204&quot;,
  &quot;baseVersion&quot;: 7,
  &quot;payload&quot;: {
    &quot;result&quot;: &quot;passed&quot;,
    &quot;notes&quot;: &quot;All safety checks completed&quot;
  },
  &quot;status&quot;: &quot;pending&quot;,
  &quot;createdAt&quot;: &quot;2026-11-17T14:30:00Z&quot;
}</code></pre>



<p class="wp-block-paragraph">The identifier must remain unchanged across retries. Generating a new identifier for every network attempt would defeat the purpose of idempotency.</p>



<p class="wp-block-paragraph">The baseVersion field records the server version against which the change was made. It will later help detect conflicting updates.</p>



<h2 class="wp-block-heading">IndexedDB provides the local transaction boundary</h2>



<p class="wp-block-paragraph">IndexedDB is designed for structured browser-side storage. Unlike localStorage, it supports transactions over object stores, indexes and asynchronous operations.</p>



<p class="wp-block-paragraph">A useful schema might contain three stores: records for the application&#8217;s local working data, outbox for pending operations, and syncMetadata for synchronization checkpoints.</p>



<p class="wp-block-paragraph">When a user edits a record, the local change and its outbox operation should be written in one IndexedDB readwrite transaction. Otherwise, the application could display a saved change without having recorded the operation needed to synchronize it.</p>



<p class="wp-block-paragraph">The following simplified implementation assumes an already opened IndexedDB database with records and outbox object stores, both keyed by id.</p>



<pre class="wp-block-code"><code class="" data-line="">function saveInspectionLocally(db, inspection) {
  return new Promise((resolve, reject) =&gt; {
    const tx = db.transaction(
      &#091;&quot;records&quot;, &quot;outbox&quot;],
      &quot;readwrite&quot;
    );

    const operationId = crypto.randomUUID();

    tx.objectStore(&quot;records&quot;).put({
      ...inspection,
      syncStatus: &quot;pending&quot;
    });

    tx.objectStore(&quot;outbox&quot;).put({
      id: operationId,
      type: &quot;inspection.completed&quot;,
      entityId: inspection.id,
      baseVersion: inspection.version,
      payload: {
        result: inspection.result,
        notes: inspection.notes
      },
      status: &quot;pending&quot;,
      createdAt: new Date().toISOString()
    });

    tx.oncomplete = () =&gt; resolve(operationId);
    tx.onerror = () =&gt; reject(tx.error);
    tx.onabort = () =&gt; reject(
      tx.error ?? new Error(&quot;Transaction aborted&quot;)
    );
  });
}</code></pre>



<p class="wp-block-paragraph">The transaction succeeds as a unit or aborts. The interface should report the local save as successful only after the transaction completes.</p>



<p class="wp-block-paragraph">IndexedDB transactions have important lifecycle rules: applications should not perform unrelated asynchronous network work inside an active transaction and assume it will remain open. The transaction may become inactive while JavaScript waits.</p>



<p class="wp-block-paragraph">Browser storage is also not equivalent to a guaranteed permanent server record. Quota limits, user-initiated data clearing, storage eviction and device failure remain relevant. Applications handling important offline work should evaluate persistent-storage requests, storage monitoring and recovery policies.</p>



<h2 class="wp-block-heading">Use Web Locks to coordinate the synchronization workflow</h2>



<p class="wp-block-paragraph">Once the outbox exists, several tabs may attempt to process it. This is where Web Locks becomes useful.</p>



<p class="wp-block-paragraph">The following coordinator allows one cooperating browser context to process the outbox at a time. It does not require an application-wide server lock or a database table lock.</p>



<pre class="wp-block-code"><code class="" data-line="">async function synchronizeOutbox() {
  if (!navigator.locks) {
    throw new Error(
      &quot;Web Locks unavailable: use a supported fallback&quot;
    );
  }

  return navigator.locks.request(
    &quot;field-service-outbox&quot;,
    { ifAvailable: true },
    async lock =&gt; {
      if (lock === null) {
        return &quot;another-context-is-syncing&quot;;
      }

      const operations = await getPendingOperations();

      for (const operation of operations) {
        try {
          const response = await fetch(&quot;/api/operations&quot;, {
            method: &quot;POST&quot;,
            headers: {
              &quot;Content-Type&quot;: &quot;application/json&quot;,
              &quot;Idempotency-Key&quot;: operation.id
            },
            body: JSON.stringify(operation)
          });

          if (response.status === 409) {
            await markOperationConflict(operation.id);
            continue;
          }

          if (!response.ok) {
            throw new Error(
              `Synchronization failed: ${response.status}`
            );
          }

          await markOperationCompleted(
            operation.id,
            await response.json()
          );
        } catch (error) {
          console.error(&quot;Sync interrupted&quot;, error);
          break;
        }
      }

      return &quot;sync-attempt-finished&quot;;
    }
  );
}</code></pre>



<p class="wp-block-paragraph">The example assumes that getPendingOperations(), markOperationConflict() and markOperationCompleted() are implemented using IndexedDB transactions. A production implementation must also handle authentication, response validation, operation ordering, retry policies and storage failures.</p>



<p class="wp-block-paragraph">The exclusive lock covers the complete synchronization attempt. Another cooperating tab cannot enter the same named critical section until the first callback finishes.</p>



<p class="wp-block-paragraph">Using ifAvailable avoids accumulating redundant synchronization requests. A tab that cannot obtain the lock simply leaves the existing worker to continue.</p>



<p class="wp-block-paragraph">This approach assumes all synchronization entry points use the same lock name. If a service worker, page or other component bypasses that convention, the lock cannot protect the workflow.</p>



<h2 class="wp-block-heading">The unavoidable failure: the server commits, but the response disappears</h2>



<p class="wp-block-paragraph">Consider a synchronization request that reaches the server successfully. The server records the completed inspection and commits its database transaction. Before the response reaches the browser, the network connection fails.</p>



<p class="wp-block-paragraph">The browser cannot know whether the operation was committed. Its local outbox still contains a pending entry.</p>



<p class="wp-block-paragraph">When connectivity returns, the application retries the same operation. Without server-side protection, the retry could apply the business action twice.</p>



<p class="wp-block-paragraph">This is why a Web Lock is insufficient. It coordinates simultaneous browser activity, but it cannot resolve uncertainty about a completed remote transaction.</p>



<h2 class="wp-block-heading">Idempotency belongs on the server</h2>



<p class="wp-block-paragraph">The server should treat the operation identifier as an idempotency key. It must enforce uniqueness within an appropriate scope, such as the authenticated account and operation identifier.</p>



<p class="wp-block-paragraph">When the same operation is submitted again, the server returns the recorded result rather than applying the business change again.</p>



<p class="wp-block-paragraph">Crucially, recording the idempotency result and applying the business mutation must belong to the same database transaction, or to a design with equivalent atomic guarantees. Otherwise, a crash between the two steps could still produce inconsistent behavior.</p>



<p class="wp-block-paragraph">The server should also reject reuse of an idempotency key with a different operation payload. The key identifies one logical operation, not an unlimited permission to submit unrelated changes.</p>



<p class="wp-block-paragraph">Idempotency does not mean every business action can safely be repeated. It means the system recognizes repeated delivery of the same logical request and avoids repeating its effects.</p>



<h2 class="wp-block-heading">Concurrent edits require a conflict policy</h2>



<p class="wp-block-paragraph">Now consider a different failure. The technician edits inspection version 7 while offline. Meanwhile, another employee updates the same inspection on the server, creating version 8.</p>



<p class="wp-block-paragraph">When the offline operation arrives, blindly overwriting the server record could discard the other employee&#8217;s work.</p>



<p class="wp-block-paragraph">One solution is optimistic concurrency control. The client submits the version it originally read, and the server accepts the update only if that version is still current.</p>



<pre class="wp-block-code"><code class="" data-line="">UPDATE inspections
SET result = :result,
    notes = :notes,
    version = version + 1
WHERE id = :inspection_id
  AND version = :expected_version;</code></pre>



<p class="wp-block-paragraph">If no row is updated, the application must distinguish a missing record from a version conflict and apply the appropriate business policy.</p>



<p class="wp-block-paragraph">The browser might ask the user to reconcile changes, merge independent fields or preserve both versions for review. Last-write-wins is possible, but it should be an explicit product decision rather than an accidental consequence of request timing.</p>



<h2 class="wp-block-heading">Service workers are execution opportunities, not permanent background processes</h2>



<p class="wp-block-paragraph">A service worker can help an offline application intercept requests, cache application resources and respond to supported background events. But it should not be designed as a permanently running synchronization daemon.</p>



<p class="wp-block-paragraph">Browsers can terminate service workers when they are idle. The Background Synchronization API can schedule deferred work in supporting browsers, but it is not universally available and should not be treated as a guaranteed execution schedule.</p>



<p class="wp-block-paragraph">A robust design uses several opportunities to attempt synchronization: application startup, user-triggered retry, restoration of network connectivity and supported service-worker synchronization events.</p>



<p class="wp-block-paragraph">Each entry point should invoke the same underlying synchronization protocol. Repeated triggers must be safe because the application cannot assume that a particular event will fire exactly once.</p>



<h2 class="wp-block-heading">Recovery is a state machine, not a boolean</h2>



<p class="wp-block-paragraph">A single isSynced flag is rarely sufficient for a reliable outbox. Operations may be pending, currently attempted, awaiting retry, rejected because of a conflict or successfully acknowledged.</p>



<p class="wp-block-paragraph">These states should have defined transitions and recovery behavior. A browser crash during an attempted operation must not leave that operation permanently inaccessible.</p>



<p class="wp-block-paragraph">One practical design keeps the durable outbox record until the server acknowledges it. A transient in-progress marker may be useful for diagnostics, but recovery must be able to reconsider interrupted work.</p>



<p class="wp-block-paragraph">For larger queues, applications can introduce retry timestamps, attempt counters, bounded batches and exponential backoff with jitter. Permanent validation failures should not block unrelated operations indefinitely.</p>



<p class="wp-block-paragraph">Dependencies between operations also matter. An inspection cannot always be synchronized before its parent work order exists on the server. The outbox may therefore need dependency ordering rather than simple chronological processing.</p>



<h2 class="wp-block-heading">Measure reliability, not merely synchronization speed</h2>



<p class="wp-block-paragraph">Offline synchronization creates valuable operational signals. Teams should measure the number of pending operations, time from local save to server acknowledgement, retry frequency, conflict rates and operations abandoned before successful delivery.</p>



<p class="wp-block-paragraph">These measurements help distinguish network problems from application defects. A high retry rate may indicate unstable connectivity, while repeated version conflicts may reveal a workflow that allows too many employees to edit the same records independently.</p>



<p class="wp-block-paragraph">Telemetry should avoid unnecessarily collecting the contents of offline business records. Operation identifiers, timestamps, status codes and appropriately aggregated metrics are often sufficient for diagnosing synchronization behavior.</p>



<h2 class="wp-block-heading">Four consistency boundaries, four different responsibilities</h2>



<ul class="wp-block-list">
<li><strong>IndexedDB transactions:</strong> preserve consistency among related local storage changes.</li>



<li><strong>Web Locks:</strong> coordinate cooperating browser contexts executing a shared workflow.</li>



<li><strong>Server-side idempotency:</strong> prevent duplicate effects when network requests are retried.</li>



<li><strong>Optimistic concurrency:</strong> detect changes made against an outdated version of a business record.</li>
</ul>



<p class="wp-block-paragraph">None of these mechanisms replaces the others. They address different failure boundaries.</p>



<p class="wp-block-paragraph">The most important architectural decision is to avoid pretending that a browser, a network and a server share one atomic transaction. They do not.</p>



<p class="wp-block-paragraph">Reliable offline applications accept that operations may be interrupted, delivered more than once or completed in an unexpected order. They preserve enough durable state to recover, identify repeated work and make conflicts visible instead of silently losing data.</p>



<p class="wp-block-paragraph">Web Locks is one useful component of that architecture. The larger engineering challenge is designing a synchronization protocol that remains correct even when the lock disappears, the network fails or another user changes the underlying data.</p>




<p class="wp-block-paragraph"></p>
]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/browser-concurrency-web-locks-indexeddb-offline-sync.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/browser-concurrency-web-locks-indexeddb-offline-sync.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
		<entry>
		<author>
			<name>Hatem Ben Yacoub</name>
							<uri>http://hbyconsusltancy.com</uri>
						</author>

		<title type="html"><![CDATA[The Export Button Is There. Is the Data Actually Usable?]]></title>
		<link rel="alternate" type="text/html" href="https://phpmagazine.net/2026/11/the-export-button-is-there-is-the-data-actually-usable.html" />

		<id>https://phpmagazine.net/?p=35396</id>
		<updated>2026-11-17T01:00:50Z</updated>
		<published>2026-11-17T20:00:00Z</published>
		<category scheme="https://phpmagazine.net" term="Business Management" /><category scheme="https://phpmagazine.net" term="Business Continuity" /><category scheme="https://phpmagazine.net" term="data exports" /><category scheme="https://phpmagazine.net" term="data portability" /><category scheme="https://phpmagazine.net" term="SAAS" /><category scheme="https://phpmagazine.net" term="Software Procurement" /><category scheme="https://phpmagazine.net" term="vendor evaluation" />
		<summary type="html"><![CDATA[A software demonstration ends with a reassuring feature: an export button. The buyer clicks it, receives a spreadsheet and moves on to pricing. Months later, the organization tries to use that export in another system and discovers that attachments, custom fields and the relationships between records are missing. The button worked. The business still did [&#8230;]]]></summary>

					<content type="html" xml:base="https://phpmagazine.net/2026/11/the-export-button-is-there-is-the-data-actually-usable.html"><![CDATA[

<p class="wp-block-paragraph">A software demonstration ends with a reassuring feature: an export button. The buyer clicks it, receives a spreadsheet and moves on to pricing. Months later, the organization tries to use that export in another system and discovers that attachments, custom fields and the relationships between records are missing.</p>



<p class="wp-block-paragraph">The button worked. The business still did not receive everything it needed.</p>



<p class="wp-block-paragraph">For organizations choosing a hosted application, export deserves a practical test before purchase. The question is not only whether data can be downloaded, but whether the result can support the work the organization may need to do with it.</p>



<h2 class="wp-block-heading">Define a real use case first</h2>



<p class="wp-block-paragraph">“We need our data” is a reasonable starting point, but it leaves too much open to interpretation. Identify the business activity the export must support. Is the organization keeping an audit record, producing a report, moving to another application or restoring operations after a service ends?</p>



<p class="wp-block-paragraph">Each use case needs different information. A spreadsheet of customer names may be enough for a mailing review. A migration may also need addresses, transaction histories, consent records, attachments and the identifiers connecting those items. An archive may need timestamps and information about who made a change.</p>



<p class="wp-block-paragraph">Write down a representative set of records and relationships before asking the supplier for a demonstration. Include the exceptions: a customer with two addresses, an order with several items, a corrected invoice and a record containing an attachment. Those cases are more revealing than a single clean row.</p>



<h2 class="wp-block-heading">Inspect the contents, not just the format</h2>



<p class="wp-block-paragraph">CSV, JSON and other formats can all be useful. A familiar extension, however, does not guarantee a complete or understandable export. Ask which fields are included, whether custom fields appear, how dates and currencies are represented, and whether deleted or archived records are available when relevant.</p>



<p class="wp-block-paragraph">Relationships are especially easy to miss. If orders and customers are exported in separate files, is there a stable identifier that connects them? If a record links to an uploaded document, does the export contain the document, a valid reference to it or only its filename? Can the organization distinguish two people with the same name?</p>



<p class="wp-block-paragraph">Ask for a data dictionary or other documentation explaining the fields and identifiers. A file full of internal codes may be technically readable while remaining difficult for another team to interpret.</p>



<h2 class="wp-block-heading">Run a representative test</h2>



<p class="wp-block-paragraph">With the supplier’s agreement, populate a trial environment with fictitious records that reflect the organization’s real workflows. Export them and inspect the result. Where migration is the intended use, ask the receiving team to attempt an import or reconstruction of a small sample.</p>



<p class="wp-block-paragraph">Compare the source and exported records. Count the records, check selected values and follow the relationships between them. Open the attachments. Check accented characters, time zones and empty fields. Document what worked, what was omitted and what required manual transformation.</p>



<p class="wp-block-paragraph">A successful sample does not prove that a full migration will be effortless. Large datasets may encounter limits, and the destination may use a different data model. The test does reveal whether the buyer and supplier share the same understanding of the feature.</p>



<h2 class="wp-block-heading">Ask about access, timing and cost</h2>



<p class="wp-block-paragraph">Determine who can run an export, how long it takes, whether it includes all workspaces and whether there are size or frequency limits. Is the function available in the proposed subscription, or does a complete export require a paid service? What assistance can the supplier provide, and what is outside its responsibility?</p>



<p class="wp-block-paragraph">Also establish what happens when an account is suspended or a subscription ends. A product may allow self-service export during an active subscription but offer a different process afterward. The buyer should understand the relevant terms and any applicable obligations before relying on a particular outcome.</p>



<h2 class="wp-block-heading">Protect the exported copy</h2>



<p class="wp-block-paragraph">An export can concentrate sensitive information in a single file. Decide who may request it, where it will be stored, how it will be transferred and when temporary copies will be removed. The people evaluating the export do not need access to real customer information if representative fictitious data will answer the question.</p>



<p class="wp-block-paragraph">Finally, record the agreed capabilities and unresolved gaps in the purchasing decision. A product with an imperfect export may still be the right choice if the organization understands and accepts the limitation. A short, documented test gives that decision substance—and makes an attractive button easier to evaluate.</p>

]]></content>
		
					<link rel="replies" type="text/html" href="https://phpmagazine.net/2026/11/the-export-button-is-there-is-the-data-actually-usable.html#comments" thr:count="0" />
			<link rel="replies" type="application/atom+xml" href="https://phpmagazine.net/2026/11/the-export-button-is-there-is-the-data-actually-usable.html/feed/atom" thr:count="0" />
			<thr:total>0</thr:total>
			</entry>
	</feed>

<!-- plugin=object-cache-pro client=phpredis metric#hits=3547 metric#misses=8 metric#hit-ratio=99.8 metric#bytes=1778514 metric#prefetches=81 metric#store-reads=56 metric#store-writes=3 metric#store-hits=167 metric#store-misses=2 metric#sql-queries=0 metric#ms-total=4010.73 metric#ms-cache=279.33 metric#ms-cache-avg=4.8161 metric#ms-cache-ratio=7.0 sample#redis-hits=32037930 sample#redis-misses=726522 sample#redis-hit-ratio=97.8 sample#redis-ops-per-sec=88 sample#redis-evicted-keys=1897 sample#redis-used-memory=198447312 sample#redis-used-memory-rss=99332096 sample#redis-memory-fragmentation-ratio=0.5 sample#redis-connected-clients=5 sample#redis-tracking-clients=0 sample#redis-rejected-connections=0 sample#redis-keys=185787 -->
