Welcome Guest, Not a member yet? Register   Sign In
Star AssetConnect - a powerful file management solution for CodeIgniter 4 applications
Posted by: maniaba - 8 hours ago - No Replies

Introducing AssetConnect for CodeIgniter 4!

Hey team! I'm excited to share a new library I've been working on called AssetConnect - a powerful file management solution for CodeIgniter 4 applications.

What is AssetConnect?

AssetConnect is a robust file management library that allows you to associate files with any entity in your application. It provides a flexible, type-safe API for handling file uploads, storage, and retrieval with powerful features.

Key Features ✨

Entity Association: Easily attach files to any entity in your application (users, products, posts, etc.)
Collections: Organize files into logical groups with specific rules and constraints
Custom Properties: Store and retrieve metadata with your files
Type-safe API: Full IDE support with strong typing
Secure Access Control: Built-in authorization checks for file access
Filtering System: Powerful query capabilities to find exactly the files you need
Queue Integration: Background processing for file operations

Example Usage ?

PHP Code:
// Add an asset to a user
$asset $user->addAsset('/path/to/file.jpg')
    ->withCustomProperties([
        'title' => 'Profile Picture',
        'description' => 'User profile picture'
    ])
    ->toAssetCollection(ImagesCollection::class);
// Get assets from a specific collection
$images $user->getAssets(ImagesCollection::class);
// Get the URL to an asset
$url $user->getFirstAsset()->getUrl(); 


Why Use AssetConnect?

Simplified File Management: No more complex file handling code scattered throughout your application
Flexible & Extensible: Create custom collections with specific rules for different types of files
Performance Optimized: Background processing for heavy operations
Secure By Design: Built with security best practices

Documentation & Resources ?

I've created comprehensive documentation that covers everything from basic usage to advanced configurations:
Documentation: https://maniaba.github.io/asset-connect/
GitHub Repository: https://github.com/maniaba/asset-connect

Get Involved! ?

I'd love for you to try out AssetConnect in your projects and provide feedback! There are several ways to contribute:

1. Try it out: Install it in your project and let me know how it works for you
2. Report issues: Found a bug or have a suggestion? Open an issue on GitHub
3. Contribute code: Pull requests are welcome! Check out the CONTRIBUTING.md file for guidelines
4. Spread the word: If you find it useful, share it with others in the CodeIgniter community

Requirements

• PHP 8.3 or higher
• CodeIgniter 4.6 or higher
• CodeIgniter Queue

Let me know if you have any questions or need help getting started! I'm excited to see how you'll use AssetConnect in your projects! ?


  The pipe operator in PHP 8.5
Posted by: InsiteFX - Yesterday, 04:18 PM - No Replies

The pipe operator in PHP 8.5


  Happy 4th Everyone
Posted by: InsiteFX - 07-03-2025, 09:31 PM - No Replies

Happy 4th of July Everyone.


  Table (view class) Row ID
Posted by: chenzen - 07-03-2025, 02:24 PM - Replies (1)

Can we have table rows accept a row id ? so the output of a row can be <tr id="some_id">.....</tr>


  AbuseIPDB Module
Posted by: grimpirate - 07-02-2025, 07:59 PM - Replies (5)

I'm working on a module for CodeIgniter4 to provide ip blocking: https://github.com/grimpirate/abuseipdb

I've run into an issue where I have a migration located under modules/AbuseIpdb/Database/Migrations.

After completing the setup and creating the SQLite database (php spark db:create abuseipdb --ext db) I attempt: php spark migrate

It's my understanding from the docs that migrations are auto-detected and run across every namespace. However, in practice, that did not occur. My migrations do not run. If I move the file from modules/AbuseIpdb/Database/Migrations into app/Database/Migrations and run the migration then it works (even without changing the namespace).

What am I doing wrong here?


  curl + response body
Posted by: okatse - 07-02-2025, 11:50 AM - Replies (5)

Hi
I am sending a request using curl, and in response, I receive


Code:
HTTP/1.1 200 Connection established

HTTP/1.1 100 Continue
Connection: keep-alive

HTTP/1.1 202 Accepted
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
strict-transport-security: max-age=31536000 ; includeSubDomains
x-frame-options: DENY
Content-Type: application/json
Content-Length: 56
Date: Wed, 02 Jul 2025 18:37:21 GMT
Connection: keep-alive

{"Id":"83589c7e-bd86-4101-8d93-3f2e7954e48e"}

echo $response->getBody();  give me headers and json

Code:
HTTP/1.1 202 Accepted
Vary: Origin,Access-Control-Request-Method,Access-Control-Request-Headers, Accept-Encoding
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
strict-transport-security: max-age=31536000 ; includeSubDomains
x-frame-options: DENY
Content-Type: application/json
Content-Length: 56
Date: Wed, 02 Jul 2025 18:37:21 GMT
Connection: keep-alive
{"Id":"83589c7e-bd86-4101-8d93-3f2e7954e48e"}
Is this some kind of error in CURLRequest.php?


My suggestion

In class CURLRequest this code

       
Code:
$output = $this->sendRequest($curlOptions);

        // Set the string we want to break our response from
        $breakString = "\r\n\r\n";
       
        while (str_starts_with($output, 'HTTP/1.1 100 Continue')) {
            $output = substr($output, strpos($output, $breakString) + 4);
        }

        if (preg_match('/HTTP\/\d\.\d 200 Connection established/i', $output)) {
            $output = substr($output, strpos($output, $breakString) + 4);
        }

        // If request and response have Digest
        if (isset($this->config['auth'][2]) && $this->config['auth'][2] === 'digest' && str_contains($output, 'WWW-Authenticate: Digest')) {
            $output = substr($output, strpos($output, $breakString) + 4);
        }

        // Split out our headers and body
        $break = strpos($output, $breakString);

        if ($break !== false) {
            // Our headers
            $headers = explode("\n", substr($output, 0, $break));

            $this->setResponseHeaders($headers);

            // Our body
            $body = substr($output, $break + 4);
            $this->response->setBody($body);
        } else {
            $this->response->setBody($output);
        }

        return $this->response;

Change to

Code:
    $output = $this->sendRequest($curlOptions);
    $parts = explode("\r\n\r\n", $output);
    $body = array_pop($parts);
    $headers = array_pop($parts);
    $this->setResponseHeaders($headers);
    $this->response->setBody($body);
    return $this->response;


  Heads up for users using Laragon:
Posted by: InsiteFX - 07-02-2025, 04:00 AM - Replies (2)

Heads up for users using Laragon:
Today Laragon's Auto Update downloaded php 8.4.9 to my system php throws a No Input File Error!
on an application that was running fine on php 8.4.7.

I tracked down the problem and just letting you know what it was!

Auto Update is sending the php-8.4.9-NTS-Win32-vs17-x64
This Non Safe Thread PHP will not run on a Windows 11 System

It requires the php-8.4.9-Win32-vs17-x64 Thread Safe PHP

I had to turn Auto Update off and manually install the correct PHP version for it to run.
So far CodeIgniter 4.6.1 is running fine under PHP 8.4.9


  Block IP addresses of bad visitors
Posted by: sevmusic - 06-30-2025, 07:37 PM - Replies (3)

Recently, we've noticed in the logs an increase of bad actors trying to access files that do not exist. More likely just bots looking for weaknesses.


For example: 

In our logs I see this:
CRITICAL - 2025-06-04 07:07:59 --> CodeIgniter\HTTP\Exceptions\BadRequestException: The URI you submitted has disallowed characters: "1'"1000"
[Method: GET, Route: about/1%27%221000]

CRITICAL - 2025-06-04 07:08:00 --> CodeIgniter\HTTP\Exceptions\BadRequestException: The URI you submitted has disallowed characters: "1'"1000"
[Method: GET, Route: about/index/1%27%221000]

etc... There are about 7,000 entries like this all with different iterations.
Is there a way I can block this user/bot if they hit 3 or more bad URLs?

Or, if I can get an email notification of their IP address so I can block them in our cPanel.

Thanks for your attention.


  The Hidden Cost of “Innovation” By Overly Frequent Development Cycles
Posted by: gosocial2 - 06-30-2025, 03:57 AM - Replies (5)

The tech industry's focus on rapid development cycles has led to substantial instability within the developer ecosystem, where developers are increasingly burdened as uncompensated maintainers of fragile foundations. This instability, evident in ecosystems based-on JavaScript and Python, emerges from dependency cascades that disrupt projects when critical components are deprecated or updated with breaking changes. Developers face productivity losses and technical debt as they are forced to rebuild applications, retrain on new paradigms, and rediscover previously solved issues. 

  • Why your React/Next.js/Python/SwiftUI/.NET project WILL break sooner rather than later (and ChatGPT / Claude/ Gemini will not fix it soon enough)
  • The dependency hells of NPM and PIP that are killing projects
  • How tech giants profit from developer suffering
  • Why "continuous learning and improvement" has become a psychological trap for developers
  • The real cost of "moving fast and breaking things" (mostly paid at a higher price by startups and small businesses)

[Video: https://www.youtube.com/watch?v=VaKVc4rprxg]
https://www.youtube.com/watch?v=VaKVc4rprxg


  Validation does not appear
Posted by: Tokioshy - 06-29-2025, 07:48 AM - Replies (4)

I was facing an issue where the validation doesn't appear. The code should be make the `form-control` had the `is-invalid` class when there is an error. In my case, the validation appear on the "Session User Data", but when I check the "View Data", the validation doesn't appear on the "protected errors" (As far as I remember, it should be there).

Controller:

PHP Code:
<?php
public function register()
{
    $data = [
        'validation' => $this->validation
    
];

    return view('auth/register'$data);
}

public function 
save()
{
    if (!$this->validate([
        'username' => [
            'rules' => 'required|min_length[3]|max_length[50]|is_unique[users.username]',
            'errors' => [
                'required' => 'Username is required.',
                'min_length' => 'Username must be at least 3 characters long.',
                'max_length' => 'Username cannot exceed 50 characters.',
                'is_unique' => 'Username already exists.'
            ]
        ],
        'email' => [
            'rules' => 'required|valid_email|is_unique[users.email]',
            'errors' => [
                'required' => 'Email is required.',
                'valid_email' => 'Email must be a valid email address.',
                'is_unique' => 'Email already exists.'
            ]
        ],
        'password' => [
            'rules' => 'required|min_length[8]',
            'errors' => [
                'required' => 'Password is required.',
                'min_length' => 'Password must be at least 8 characters long.'
            ]
        ]
    ])) {
        return redirect()->to('/auth/register')->withInput();
    }

    $this->user->save([
        'username' => $this->request->getVar('username'),
        'email' => $this->request->getVar('email'),
        'password' => password_hash($this->request->getVar('password'), PASSWORD_DEFAULT)
    ]);

    session()->setFlashdata('success''Registration successful! You can now log in.');

    return redirect()->to('auth/login');


Views:

Code:
<form method="post" action="<?= base_url('auth/save'); ?>">
    <?= csrf_field(); ?>
    <div class="mb-3">
        <label for="username" class="form-label">Username</label>
        <input type="text" class="form-control <?= ($validation->hasError('username')) ? 'is-invalid' : ''; ?>" value="<?= old('username'); ?>" id="username" name="username" placeholder="Enter your username" required>
        <div class="invalid-feedback">
            <?= $validation->getError('username'); ?>
        </div>
    </div>
    <div class="mb-3">
        <label for="email" class="form-label">Email address</label>
        <input type="email" class="form-control <?= ($validation->hasError('email')) ? 'is-invalid' : ''; ?>" value="<?= old('email'); ?>" id="email" name="email" placeholder="Enter your email" required>
        <div class="invalid-feedback">
            <?= $validation->getError('email'); ?>
        </div>
    </div>
    <div class="mb-3">
        <label for="password" class="form-label">Password</label>
        <input type="password" class="form-control <?= ($validation->hasError('password')) ? 'is-invalid' : ''; ?>" id="password" name="password" placeholder="Enter your password" required>
        <div class="invalid-feedback">
            <?= $validation->getError('password'); ?>
        </div>
    </div>
    <div class="d-grid mb-3">
        <button type="submit" class="btn btn-primary">Register</button>
    </div>
    <div class="text-center">
        <a href="login" class="d-block text-decoration-none mt-2">Back to Login</a>
    </div>
</form>

Screenshot:

[Image: ZMS8JAu.png]
[Image: WHQjZbw.png]
[Image: 2q4kotF.png]


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
AssetConnect - a powerful...
by maniaba
8 hours ago
twig and view cell
by foxbille
10 hours ago
Best Way to Implement Aff...
by InsiteFX
Yesterday, 09:58 PM
The pipe operator in PHP ...
by InsiteFX
Yesterday, 04:18 PM
Heads up for users using ...
by FlavioSuar
Yesterday, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
curl + response body
by michalsn
07-03-2025, 10:10 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 154,888
» Latest member: fi88vnapp
» Forum threads: 78,441
» Forum posts: 379,731

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB