Welcome Guest, Not a member yet? Register   Sign In
  downloading a file new tab
Posted by: cbazan - 5 hours ago - No Replies

Hello. I have within a controller the option to download a file so that it can be seen in the Browser with the following command:

Code:
return $this->response->download($filename, $data], true)->inline();
The uri that calls the function or method to download the file is https://xxxxxxxx.xxx/download/docs/invoice/1 and the problem is that the title of the new open tab, corresponds to the latest segment of the URL, which is 1 and also puts the size of the unloaded file and I need to change that title to something different.
How can I do that?
Thanks in advance.


  What's New in PHP 8.5: A Comprehensive Overview
Posted by: InsiteFX - 07-11-2025, 08:50 PM - No Replies


  Session Not Persisting After Redirect in CodeIgniter 4
Posted by: mepcodevhub - 07-10-2025, 04:34 AM - Replies (2)

Hi everyone,
I’m running into a weird issue with sessions in CodeIgniter 4 and I’d really appreciate some help.

I’m setting a session value in one controller, then doing a redirect to another controller or method. I expect the session data to be available after the redirect.

The session is getting set fine, but after the redirect, the session seems empty or sometimes only partially saved. I’m using the default file-based session driver.

  • Double-checked
    Code:
    Config\App.php
    session settings — using default file handler.
  • Tried
    Code:
    session()->markAsFlashdata()
    and also regular
    Code:
    set()
    but same result.
  • Confirmed cookies are enabled.
  • Cleared cache and tried different browsers — same issue.
My questions:
  1. Is there something special I need to do to make sure sessions persist correctly after
    Code:
    return redirect()->to()
    ?
  2. Could it be a write timing issue? Do I need to manually call
    Code:
    session()->close()
    before redirecting?
  3. Are there any best practices to debug this?
Any suggestions or working examples would really help.
Thanks a lot in advance!


  Web Automation and Scraping in CodeIgniter 4
Posted by: mepcodevhub - 07-06-2025, 04:51 AM - Replies (3)

Hi Everyone, ?
I’m currently working on a personal project (might turn into my final year submission) where I need to automate some tasks and scrape data from external websites — basically without using any third-party API. I’m aware this is often done using cURL or libraries like Guzzle in raw PHP.
But since I’ve chosen CodeIgniter 4 for this project, I’m curious:

  • Is it a good idea to implement web scraping or automation logic directly in a CI4 controller/service?
  • Can I integrate tools like cURL or Simple HTML DOM Parser in CodeIgniter without breaking the framework structure?
  • Are there any recommended CI4-friendly libraries for scraping?
Any suggestions or examples would be really helpful. I want to make sure I’m going about this the right way. ?
Thanks in advance!


Star AssetConnect - a powerful file management solution for CodeIgniter 4 applications
Posted by: maniaba - 07-05-2025, 03:53 AM - Replies (2)

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 - 07-04-2025, 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 (6)

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;


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

Username
  

Password
  





Latest Threads
downloading a file new ta...
by cbazan
5 hours ago
Session Not Persisting Af...
by captain-sensible
Yesterday, 04:16 AM
What's New in PHP 8.5: A ...
by InsiteFX
07-11-2025, 08:50 PM
Web Automation and Scrapi...
by InsiteFX
07-10-2025, 09:21 PM
Server Push/preloading?
by mepcodevhub
07-10-2025, 04:37 AM
Best Way to Implement Aff...
by InsiteFX
07-07-2025, 03:06 AM
curl + response body
by michalsn
07-06-2025, 10:14 PM
AssetConnect - a powerful...
by Crenel
07-06-2025, 04:08 PM
twig and view cell
by foxbille
07-05-2025, 01:58 AM
The pipe operator in PHP ...
by InsiteFX
07-04-2025, 04:18 PM

Forum Statistics
» Members: 156,343
» Latest member: mn88888com
» Forum threads: 78,445
» Forum posts: 379,745

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB