PHP Reddit – Telegram
PHP Reddit
34 subscribers
289 photos
37 videos
24.8K links
Channel to sync with /r/PHP /r/Laravel /r/Symfony. Powered by awesome @r_channels and @reddit2telegram
Download Telegram
Plea for help! Does anyone have/know where I could obtain the brandonwamboldt/utilphp package?

Hello!

I've got a very old Dockerised project, for the website of a family member's small business, it was built \~8 years ago with Bolt CMS 3.2, and has basically been ticking along unmaintained since then (if it ain't broke, don't fix it)

A dependency of Bolt is https://packagist.org/packages/brandonwamboldt/utilphp, however at some time in the last year, the author decided to delete the Github repository.

A quirk of the project, I never got to the bottom of why, but every few months the DigitalOcean droplet runs out of disk space, so then I just run docker prune to clear all the volumes and images, and then rebuild everything 😂 (yeah it's amateurish, but it's such a basic website it's never been worth the effort to fix it properly!)

Anyway, today I discover that the project doesn't build because the above Github repository is deleted.

So, I'm posting here to ask if anyone happens to have any version of this package themselves - maybe in their own vendor folder, as a direct or indirect dependency - and if so, perhaps they could kindly share this with me? And then I could somehow work out how to hack things together so that composer recognises my own copy as the package's source.

Or, if anyone knows of a Github archive/mirror that would somehow still have this package available?

Otherwise I'll have to try and upgrade to Bolt 5 - but since a prerequisite is a working project with Bolt 3.7 - I'm not sure how possible this would be.

If anyone can help me they would really be a true lifesaver! Thank you in advance

On a sidenote - packagist says it has 538,490 installs - you hear a lot about this sort of thing happening with npm, where a package owner deletes the project and failing builds ensue - but I naively assumed composer would somehow do something to mitigate this - but I guess composer is just as vulnerable!? (Or even moreso - if I'm not mistaken npm have taken steps to remedy this - I'm not completely in the loop though so I could be wrong)

https://redd.it/1nvxt3s
@r_php
I built a PHP SDK for the Agentic Commerce Protocol (ACP), looking for testers

Hey all,

Three days ago OpenAI + Stripe dropped this new thing called Agentic Commerce Protocol (ACP). Basically it lets people buy stuff directly inside ChatGPT with instant checkout. It’s super new and I was curious, so I spent the last days hacking together a PHP SDK for it.

Repo’s here: https://github.com/shopbridge/shopbridge-php

It handles checkout sessions (create/update/complete/cancel), webhook signatures, product feeds in CSV/JSON/XML, etc. Runs on PHP 7.4+.

This is all open source / MIT. I honestly just want people to try it out, break it, tell me what sucks, or maybe even use it in a test project. Happy to help if you want to play with ACP for your shop or a client.

It’s all very fresh, so don’t expect production-grade yet, but if anyone here is curious, I’d love feedback.

Cheers!

https://redd.it/1nvxfe2
@r_php
Stuck with Laravel Package Tests with Pest + Orchestra Testbench - Laravel Helpers Not Available

## Context

I've developed a Laravel package that works perfectly in production, but I'm struggling to get the tests working properly. The package is located at `packages/cli/` within my Laravel application (local package development setup).

**Goal:** Run my package tests from the Laravel app root using `php artisan test`

**Current Issue:** Tests run but Laravel helper functions like `config()`, `app()`, etc. are not available. I get "Target class [config] does not exist." errors.

## What I've Done So Far

### 1. Installed Required Dependencies

**Package `composer.json`:**
```json
{
"name": "sheaf/cli",
"type": "library",
"autoload": {
"psr-4": {
"Sheaf\\Cli\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Sheaf\\Cli\\Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"providers": [
"Sheaf\\Cli\\ServiceProvider"
]
}
},
"require-dev": {
"orchestra/testbench": "^10.4",
"pestphp/pest": "^3.8",
"pestphp/pest-plugin-laravel": "^3.2"
}
}
```

### 2. Created TestCase with Orchestra Testbench

**`packages/cli/tests/TestCase.php`:**
```php
<?php

namespace Sheaf\Cli\Tests;

use Orchestra\Testbench\TestCase as Orchestra;

class TestCase extends Orchestra
{
protected function getPackageProviders($app)
{
return [
\Sheaf\Cli\ServiceProvider::class,
];
}

protected function setUp(): void
{
parent::setUp();
}
}
```

### 3. Created Pest Configuration

**`packages/cli/tests/Pest.php`:**
```php
<?php

declare(strict_types=1);
uses(\Sheaf\Cli\Tests\TestCase::class)->in('Feature', 'Unit');
```

### 4. Created Test File

**`packages/cli/tests/Feature/ExampleTest.php`:**
```php
<?php

namespace Sheaf\Cli\Tests\Feature;

test('confirm environment is set to testing', function () {
expect(config('app.env'))->toBe('testing'); // ERROR HERE
});
```

### 5. Updated Laravel App's `phpunit.xml`

```xml
<testsuites>
<testsuite name="Package">
<directory>packages/cli/tests</directory>
</testsuite>
</testsuites>
```

## The Problem

When I run tests from the Laravel app root with `php artisan test`, I get:

```
Target class [config] does not exist.
```

I added debug code to check what's happening:

```php
test('debug', function () {
dd([
'testcase_class' => get_class($this),
'parent_class' => get_parent_class($this),
'app_exists' => isset($this->app),
]);
});
```

**Output:**
```php
array:3 [
"testcase_class" => "P\Packages\cli\tests\Feature\ExampleTest"
"parent_class" => "PHPUnit\Framework\TestCase"
"app_exists" => false // Laravel app not available
]
```

## What Works

Running tests from **within the package directory** works fine:
```bash
cd packages/cli
./vendor/bin/pest
```

## What Doesn't Work

Running from Laravel app root:
```bash
php artisan test
```

## My Understanding

I believe the issue is that when running tests from the Laravel app root, Pest doesn't discover my package's `Pest.php` configuration file, so it doesn't know to use my custom TestCase.

## What I've Tried

1. Verified autoload-dev has correct namespace with trailing backslash
2. Run `composer dump-autoload` multiple times
3. Cleared Laravel caches
4. Verified Orchestra Testbench is installed
5. Package ServiceProvider loads correctly in the app (commands work)
6. Tried adding `uses(TestCase::class)` in test files (got "uses() undefined")

## Questions

1. **Is this the correct approach for testing local packages within a Laravel app?**
2. **How do I make Pest discover/use my package's TestCase when running from the app root?**
3. **Should I be using a different testing strategy for local packages?**

## Directory Structure

```
my-laravel-app/
├── app/
├── packages/
│ └── cli/
│ ├── src/
│ │ └── ServiceProvider.php
│ ├── tests/
│ │ ├── Pest.php
│ │ ├── TestCase.php
│ │ └── Feature/
│ │ └──
ExampleTest.php
│ ├── composer.json
│ └── phpunit.xml
├── tests/
├── composer.json
└── phpunit.xml
```

## Environment

- Laravel 11
- PHP 8.2
- Pest 3.8
- Orchestra Testbench 10.4

---

## Code source of my package:
https://github.com/sheafui/cli/tree/tests/configuration (within the branch `tests/configuration`)

Any guidance would be greatly appreciated! I've been stuck on this for days and can't figure out what I'm missing.

Thanks in advance! 🙏

https://redd.it/1nwdd6e
@r_php
Using ionCube in Laravel for encrypting source code

Hi -

I'm a Laravel developer (love it), going on 5 years now -

Management has requested we use ionCube... I have had mixed success with ionCube... I get a lot of unresolved class errors, unresolved methods, binding resolution errors (not sure the exact name). Each php file on its own is stand-alone encrypted, so what I do is unencrypt specific files until the errors go away...

I'm not sure if it is related to the types of design patterns Laravel uses -

Does anyone use ionCube to encrypt source code? Do you come across any challenges? How do you solve those challenges in a general sense?

Thanks -

https://redd.it/1nwzfy8
@r_php
is there any reason "Installing Composer Dependencies for Existing Applications" section removed from Laravel 12 sail documentation?

I got a new macbook pro. I decided not to use Laravel valet to keep may Macos clean, And beside that I saw wehn Googling that Laravel valet maybe discontinued in future in favor of Laravel herd. I don't like to use herd, so I decided to go with Laravel sail. but when reading the docs I found out that they removed the "Installing Composer Dependencies for Existing Applications" I was a little concerned if they are discontinuing Laravel sail to in favor of herd? or it's just they forgot to add this se section back into Laravel 12 documentations. Because it does not make sense for someone who wants to use Laravel sail with docker to install PHP and composer too into it's OS. someone like me who decides to use docker is because I don't want to install PHP and Composer. If I install those I would use valet.

https://preview.redd.it/saugkw5dswsf1.png?width=1268&format=png&auto=webp&s=e1750ebbbb2b22d171370c02d535b9d316c5f6b9



https://redd.it/1nx12ad
@r_php
Obfuscate PHP code

Couldn't find all that much besides Zend Guard and ionCube PHP Encoder.

When it comes to open source solutions the only one that stood out was YAK Pro and so far is working.

Any other, preferably open source, solutions to check out?

Also any insight on this subject is appreciated.

https://redd.it/1nxnebf
@r_php
CodeIgniter vs Laravel vs symphony for PHP developer

I'm PHP developer, who developed web apps using procedural PHP coding and have good understanding on OOP too. Now for me its time to learn one of the PHP frameworks.
I'm freelancer and also created few small web apps that are still working very well.

My plan is:

Be competent for job searching in the future if I might need to.
To replace my old and procedural PHP codes with better framework code.
To create my own startup web app.

I prefer to have:

Control and freedom
Fast and security
Fast speed of development and scalability

So which one would you choose for me based on your experiences.

Thank you in advance.

https://redd.it/1nxx8ny
@r_php
NGINX UNIT + TrueAsync

How is web development today different from yesterday? In one sentence: nobody wants to wait for a server response anymore!
Seven or ten years ago or even earlier — all those modules, components being bundled, interpreted, waiting on the database — all that could lag a bit without posing much risk to the business or the customer.

Today, web development is built around the paradigm of maximum server responsiveness. This paradigm emerged thanks to increased internet speeds and the rise of **single-page applications (SPA)**. From the backend’s perspective, this means it now has to handle as many fast requests as possible and efficiently distribute the load.
It’s no coincidence that the two-pool architecture request workers and job workers has become a classic today.

The one-request-per-process model handles loads of many “lightweight” requests poorly. It’s time for concurrent processing, where a single process can handle multiple requests.

The need for concurrent request handling has led to the requirement that server code be as close as possible to business logic code. It wasn’t like that before! Previously, web server code could be cleanly and elegantly abstracted from the noscript file using CGI or FPM. That no longer works today!

This is why all modern solutions either integrate components as closely as possible or even embed the web server as an internal module. An example of such a project is \*\*NGINX Unit\*\*, which embeds other languages, such as JavaScript, Python, Go, and others — directly into its worker modules. There is also a module for PHP, but until now PHP has gained almost nothing from direct integration, because just like before, it can only handle one request per worker.

Let’s bring this story to an end! Today, we present **NGINX Unit** running PHP in concurrent mode:
[Dockerfile](https://github.com/EdmondDantes/nginx-unit/blob/true-async/src/true-async-php/Dockerfile)

Nothing complicated:

# 1.Configuration

**unit-config.json**

{
"applications": {
"my-php-async-app": {
"type": "php",
"async": true, // Enable TrueAsync mode
"entrypoint": "/path/to/entrypoint.php",
"working_directory": "/path/to/",
"root": "/path/to/"
}
},
"listeners": {
"127.0.0.1:8080": {
"pass": "applications/my-php-async-app"
}
}
}

# 2. Entrypoint

<?php

use NginxUnit\HttpServer;
use NginxUnit\Request;
use NginxUnit\Response;

set_time_limit(0);

// Register request handler
HttpServer::onRequest(static function (Request $request, Response $response) {
// handle this!
});

It's all.

`Entrypoint.php` is executed only once, during worker startup. Its main goal is to register the `onRequest` callback function, which will be executed inside a `coroutine` for each new request.

The `Request`/`Response` objects provide interfaces for interacting with the server, enabling non-blocking write operations. Many of you may recognize elements of this interface from Python, JavaScript, Swoole, AMPHP, and so on.

This is an answer to the question of why PHP needs TrueAsync.

For anyone interested in looking under the hood — please take a look here: [NGINX UNIT + TrueAsync](https://github.com/EdmondDantes/nginx-unit/tree/true-async/src/true-async-php)

https://redd.it/1nxzpt3
@r_php
Launched a package: Laravel Auto Transaction - Simplifying Database Transaction Management

After working with Laravel applications, I noticed developers often forget to wrap critical operations in transactions or miss rollback handling. This led to data inconsistencies in production.

So I built Laravel Auto Transaction - an open-source package that automates database transaction management.

**Key Features:**

* Automatic commit on success, rollback on failure
* Middleware support for entire routes
* Built-in retry mechanism for deadlock handling
* Multi-database connection support
* Zero configuration required


This is my first Laravel package. The tests are passing, documentation is ready, and it's available on Packagist.

📦 Installation: `composer require sheum/laravel-auto-transaction`

🔗 GitHub: [github.com/laravel-auto-transaction](https://github.com/mohamadsheam/laravel-auto-transaction)

📖 Packagist: [packagist.org/laravel-auto-transaction](https://packagist.org/packages/sheum/laravel-auto-transaction)

I'd appreciate any feedback, suggestions, or contributions from the Laravel community.

Thanks

https://redd.it/1nya2h2
@r_php