Welcome Guest, Not a member yet? Register   Sign In
  How, what, where?
Posted by: HarmW94 - 03-08-2025, 04:54 PM - Replies (3)

At the moment I have an application running in CI4 but I want to rewrite it;

For the following reasons:
- Never worked with a (PHP) Framework before so the code is quite sloppy.
- It started as a hobby project, which it still is, but now about 30 people use it and this is going to grow.
- I now work in the production environment and that is of course not really the intention.

I am just getting a bit overwhelmed with all the possibilities that are now available. My knowledge in JS is quite low and so I have looked at for example React, Vue etc., but I do not know if a SPA is necessary since I only want to add a few active elements.

Now I once asked around and one advises CodeIgniter the other Laravel with for example Vue/React (Inertia) or Alpine (AJAX)... "CodeIgniter is death" etc. etc. etc.. There is too much, lol!

Have you ever faced this choice? I will always be the only one who will manage this project. 

How, what, where?


  erorr session help
Posted by: samet - 03-08-2025, 07:48 AM - Replies (1)

Ölümcül hata: Uncaught ErrorException: touch (): writable / session / ci_session7b2atemvbopvjl3vim2mdfcaviebofii dosyası oluşturulamıyor çünkü C: \ xampp \ htdocs \ htdocks \ work \ system \ Session \ Handlers \ FileHandler.phFileHandler.php (193): touch ('yazılabilir / sessio ...') # 2 [dahili işlev]: CodeIgniter \ Session \ Handlers \ FileHandler- > write ('7b2atemvbopvjl3 ...', ' ' ' '__________ [yerine] [ C:\ xampp \ htdocs \ htdocks \ vendor \ codeigniter4 \ framework \ system \ Session \ Handlers \ FileHandler.php hatta 193 
Klasörler var ve hatta söylediği dosyayı oluşturuyor ama bu hatayı alıyorum

English Translation:

Code:
Fatal error : Uncaught ErrorException: touch(): cannot create file
writable/session/ci_session7b2atemvbopvjl3vim2mdfcaviebofii
because C:\xampp\htdocs\htdocks\work\system\Session\Handlers\FileHandler.phFileHandler.php(193):
touch('writable/sessio...')#2 [internal function]:
CodeIgniter\Session\Handlers\FileHandler->write('7b2atemvbopvjl3...',' ' ''__________ [instead of][ 
C:\xampp\htdocs\htdocks\vendor\codeigniter4\framework\system\Session\Handlers\FileHandler.php  even  193
The folders exist and even create the file it says but I get this error


  passing variable - shows invalid variable ...
Posted by: arcmax98 - 03-07-2025, 02:02 AM - Replies (5)

this should have been easy.... but for some reason its not working ...
Controller..

Code:
<?php

namespace App\Controllers;

use App\Controllers\BaseController;
use App\Models\UserModel;

class Login extends BaseController
{
    public function index()
    {
        return view('login');
    }
 
    public function authenticate()
    {
        $session = session();
        $userModel = new UserModel();

        $email = $this->request->getVar('email');
        $password = $this->request->getVar('password');
       
        $user = $userModel->where('user_email', $email)->first();
       
        if(is_null($user)) {
            return redirect()->back()->withInput()->with('error', 'Invalid username or password.');
        }

        $pwd_verify = password_verify($password, $user['user_pass']);

        if(!$pwd_verify) {
            return redirect()->back()->withInput()->with('error', 'Invalid username or password.');
        }

        $ses_data = [
            'user_id' => $user['user_id'],
            'user_email' => $user['user_email'],
            'isLoggedIn' => TRUE
        ];

        $session->set($ses_data);
        $data = array("js_to_load"=> "hello");
     
       
        //$data['js_to_load']=array("https://cdn.datatables.net/2.2.2/js/dataTables.js","https://cdn.datatables.net/2.2.2/js/dataTables.tailwindcss.js");

        return view( '/dashboard', $data);
 
       
       
    }
}
View - dashboard
Code:
<?=$this->extend("layouts/postlogin_layout")?>
 
<?=$this->section("content")?>

        <?php echo $js_to_load; ?>
       
 

    <?=$this->include('partials/usersettings');?>
   
<?=$this->endSection()?>
keep getting
Quote:ErrorException - Undefined variable $js_to_load
I have tried everything ..
Code:
$this->load->view('/dashboard',$data);
return view( '/dashboard', $data);
echo view('dashboard', $data);
all give the same invalid variable
if in the view i put
Code:
print_r($_SESSION);
it print's the session...
I know i am making a very small mistake some where just dont know where ...


  composer upgrade to 4.4.8
Posted by: cadgiru - 03-06-2025, 02:06 AM - Replies (2)

Get

Code:
composer audit
The new audit.abandoned setting (currently defaulting to "report" will default to "fail" in Composer 2.7, make sure to set it to "report" or "ignore" explicitly by then if you do not want this.
Found 1 security vulnerability advisory affecting 1 package:
+-------------------+----------------------------------------------------------------------------------+
| Package          | codeigniter4/framework                                                          |
| CVE              | CVE-2025-24013                                                                  |
| Title            | Missing validation of header name and value in codeigniter4/framework            |
| URL              | https://github.com/advisories/GHSA-x5mq-jjr3-vmx6                                |
| Affected versions | <4.5.8                                                                          |
| Reported at      | 2025-01-21T21:13:40+00:00                                                        |
+-------------------+----------------------------------------------------------------------------------+
Should I be concerned? What should I do?


  public/index.php (54) require inexistent /Boot.php
Posted by: lwmirkk - 03-05-2025, 01:28 PM - Replies (1)

Hi!
Most recent Codeigniter version (4.6.0 ?)
In appstarter/public/index.php (54)
This line:

PHP Code:
// LOAD THE FRAMEWORK BOOTSTRAP FILE
require $paths->systemDirectory '/Boot.php'

The problem, the file doesn`t exists and an error is shown:
PHP Code:
/appstarter/app/Config/../../vendor/codeigniter4/framework/system/Boot.php 

The only file that exists with a similar name in this folder is : bootstrap.php
I installed the codeigniter via composer.
Sorry if noob question, I have only one other CI4 (older one) working with PHP 7.4 and many other CI3 projects in other websites (PHP 7.4), trying to adapt to the new CI4.6.
Thanks a lot! Smile


  Error Displaying PDF in Browser Using CodeIgniter 4: "Cannot modify header informatio
Posted by: williammoreschi - 03-05-2025, 12:29 PM - Replies (3)

Hello everyone!
I'm encountering an issue when trying to display a PDF file directly in the browser using CodeIgniter 4. After implementing the functionality to display the PDF in my controller, I am getting the error below: %PDF-1.5 %���� 4 0 obj <> stream adobe:docid:photoshop:7bda024c-efbc-c64c-b32e-edfd2a02ac48 endstream endobj 5 0 obj <> stream x�c 2ptqre  ��+) rwR���R`?

Even after attempting several solutions, the issue persists. In one of my attempts, it showed the following error message: "Cannot modify header information - headers already sent by (output started at /path/to/Events.php:33)"

By commenting out the ` while ` statement on line 33, the error stops, but I believe that commenting out this piece of code will cause other issues in the future.

Code I am using:

Code:
<?php
namespace App\Controllers;
class Home extends BaseController
{
    public function index()
    {
        // Path to the PDF file
        $fileName = 'ebook.pdf';
        $filePath = WRITEPATH . 'uploads/pdfs/' . $fileName;
        // Check if the file exists
        if (!file_exists($filePath)) {
            throw new \CodeIgniter\Exceptions\PageNotFoundException('File not found.');
        }
        // Set the headers manually
        return $this->response
            ->setHeader('Content-Type', 'application/pdf')
            ->setHeader('Content-Disposition', 'inline; filename="' . $fileName . '"')
            ->setHeader('Content-Transfer-Encoding', 'binary')
            ->setHeader('Content-Length', filesize($filePath))
            ->setHeader('Accept-Ranges', 'bytes')
            ->setBody(file_get_contents($filePath));  // Reads the file content and sends it
    }
}
Any idea what could be causing this issue and how to fix it?

I’m using:

Ubuntu 24.04.2
PHP 8.3.17
CodeIgniter 4.6.0
I appreciate any help!


  Shield problem with permission
Posted by: pippuccio76 - 03-05-2025, 12:52 AM - Replies (6)

HI , i set in AuthGroups this permission :

Code:
/**
    * --------------------------------------------------------------------
    * Permissions
    * --------------------------------------------------------------------
    * The available permissions in the system.
    *
    * If a permission is not listed here it cannot be used.
    */
    public array $permissions = [
        'admin.access'        => 'Can access the sites admin area',
        'admin.settings'      => 'Can access the main site settings',
        'agente.access'      => 'Può visionare l\'area admin ma con delle restrizioni per la gestione dei clienti',
        'agente.create'      => 'Può visionare l\'area admin ma con delle restrizioni per la gestione dei clienti',
        'aziende.access'      => 'Può visionare l\'area admin ma con delle restrizioni per la gestione delle tratte',
        'cliente.access'      => 'Può visionare l\'area clienti in modo di aver diritto a sconti o al pagamento a fine mese',
        'cliente.create'      => 'Può creare clienti',
        'users.manage-admins' => 'Can manage other admins',
        'users.create'        => 'Can create new non-admin users',
        'users.edit'          => 'Can edit existing non-admin users',
        'users.delete'        => 'Can delete existing non-admin users',
        'beta.access'        => 'Can access beta-level features',
    ];

    /**
    * --------------------------------------------------------------------
    * Permissions Matrix
    * --------------------------------------------------------------------
    * Maps permissions to groups.
    *
    * This defines group-level permissions.
    */
    public array $matrix = [
        'superadmin' => [
            'admin.*',
            'users.*',
            'agente.*',
            'cliente.*',
        ],
        'admin' => [
            'admin.access',
            'users.*',
            'agente.*',
        ],
        'developer' => [
            'admin.access',
            'admin.settings',
            'users.create',
            'users.edit',
            'beta.access',
        ],
        'agente' => [
            'agente.access',
            'cliente.create',
        ],
        'aziende' => [
            'aziende.access',
        ],
        'clienti' => [
            'cliente.access',
        ],
    ];
}
and create a method to show information :

Code:
    public function test()
    {
          $data = [] ;

          print_r($_SESSION);

          echo '<pre>';
          echo auth()->user()->email;
          echo '</pre>';

         
          echo '<pre>';
          var_dump(auth()->user()->getGroups());
          echo '</pre>';

          echo '<pre>';
          var_dump(auth()->user()->getPermissions());
          echo '</pre>';

          die();
                     
          echo view('empty_view', $data);
          echo view('gestionale/admin/test');
    }

this is the result :
Code:
Array ( [__ci_last_regenerate] => 1741160512 [_ci_previous_url] => http://xxxxxxxxxxxxx/index.php/admin_tratte_acquistate/lista_prenotazioni/dashboard [csrf_token_name] => f84f0989fe8038b65eb101b338c82977 [user] => Array ( [id] => 1 ) )
[email protected]

array(1) {
  [0]=>
  string(10) "superadmin"
}

array(0) {
}
why not have i any permission?


  Updating ci with composer problem with shield's route
Posted by: pippuccio76 - 03-04-2025, 01:21 PM - Replies (8)

HI , i have this error :
Call to a member function routes() on null
at APPPATH/Config/Routes_gestionale.php:19
 this is my Route.php :

Code:
<?php

use CodeIgniter\Router\RouteCollection;

/**
* @var RouteCollection $routes
*/

require 'Routes_vetrina.php';


require 'Routes_gestionale.php';

and this is my Routes_gestionale.php

Code:
<?php






############################################################################################################
############################################################################################################
#                                      GESTIONALE
############################################################################################################
############################################################################################################

/*
    * --------------------------------------------------------------------
    * AUTH
    * --------------------------------------------------------------------
    */
service('auth')->routes($routes); //line 19
How can isolve it ?


  tool bar not showing
Posted by: arcmax98 - 03-04-2025, 07:46 AM - Replies (1)

installed codeigniter 4.6 on windows computer... using php spark ...
env file

Quote:CI_ENVIRONMENT = development
app_baseURL = 'http://localhost:8080/'
config/App.php
Quote:public string $baseURL = 'http://localhost:8080/';
the actual directory is 'http://localhost:8080/ci4/' - but for some reason this works http://localhost:8080/ takes me to my index.php -> http://localhost:8080/ci4/index.php
created the files the routes ... everything seems to work
the filters has the toolbar $globals after and $required after
i just cannot see the debug bar...
what am i doing wrong ?


  URI routing from CLI
Posted by: Fido L Dido - 03-04-2025, 06:46 AM - Replies (2)

I'm encountering an issue with a route when calling it from the CLI. I think this may very well be a feature rather than a bug!
I have a cli method which expects 3 parameters all as strings. This is the route:

PHP Code:
$routes->cli('cli/postbyid/(:segment)/(:segment)/(:any)''Cli::postbyid/$1/$2/$3'); 

By and large this works, except when the third string contains characters that normally wouldn't be permitted by ar URI. For example:
Code:
php index.php cli param1 param2 param3(b)

The brackets in the third parameter cause an exception to be thrown:
Code:
CodeIgniter\HTTP\Exceptions\BadRequestException: The URI you submitted has disallowed characters: "param3(b)"

I can see that this is correct behaviour for security reasons when specifying URIs, but a CLI parameter isn't a URI.
I've tried adding a custom placeholder permitting *any* characters at all, but this still throws the same error as I suspect it is still restricted by config/App.php. Hopefully I've explained this in a way that it can be understood. I think CI is performing as designed, but is creating an unnecessary restriction for CLI access. I suspect the solution is for CLI access to ignore character restrictions on URIs, or that any custom placeholder should not be restricted by the characters specified in the config.

Edit: I'm using CI 4.6.0


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

Username
  

Password
  





Latest Threads
Magic login link not work...
by InsiteFX
1 hour ago
Is codeigniter 5 upco...
by InsiteFX
1 hour ago
Why PHP is still worth le...
by InsiteFX
6 hours ago
Any user guid or video o...
by msnisha
Yesterday, 02:30 PM
MVC vs MVCS vs CodeIgnite...
by massimiliano1.mancini
Yesterday, 10:15 AM
Is hiring a digital marke...
by Markhenry123
Yesterday, 02:45 AM
my controller fails to fi...
by PaulC
Yesterday, 01:40 AM
My Library cannot see ses...
by InsiteFX
05-08-2025, 08:48 PM
update the framework to t...
by captain-sensible
05-08-2025, 12:14 PM
CodeIgniter Shield 1.0.0 ...
by Ayatorvi
05-08-2025, 06:06 AM

Forum Statistics
» Members: 145,081
» Latest member: alo789clbcom
» Forum threads: 78,382
» Forum posts: 379,423

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB