Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all 14136 articles
Browse latest View live

PhpStorm What's New in 2024.3

$
0
0
What's New in 2024.3

This release is a major update that includes support for PHP 8.4, xdebug_notify(),
Pest 3.0, Pest parallel and mutation testing, and more. If you’re using PhpStorm
with JetBrains AI Assistant, the latter has also been updated with the new AI code
completion model, new inline AI prompting, and other improvements.


PhpStorm 2024.3

Session files

$
0
0
Hi All,

I recently saw that I had a lot of session files and wonder if the amount being created by CodeIgniter is correct. So I installed a fresh version of 4.5.5 app starter and made the following changes:-

Controller - home.php

PHP Code:
class Home extends BaseController
{
  public function index(): string
  
{
    $session service('session');
    return view('welcome_message');
  }


View - welcome_message.php

PHP Code:
<!DOCTYPE html>
<
html lang="en">
<
head>
    <meta charset="UTF-8">
    <title>Welcome to CodeIgniter 4!</title>
    <meta http-equiv="refresh" content="60"

CodeIgniter is creating a new session file every 5 minutes. I assume this is because of
Code:
public int $timeToUpdate = 300;
in Config/Session.php

Is this (many files) the expected behaviour? and if so does it make
Code:
$expiration = 7200;
redundant?

ELI5  Angel

[Image: IknZNroT]

Error Logs

$
0
0
2 SYSTEMPATH/Validation/Validation.php(339): App\Validations\Validations->Test('784520', '', [...], null, 'service')

How can i get Data instead [...] in my logs file

Cron Job Error

$
0
0
Hello everyone,
I'm trying to run a command using cron, and I get the following error:
Code:
CRITICAL - 2024-11-16 23:28:01 --> TypeError: array_shift(): Argument #1 ($array) must be of type array, null given
[Method: GET, Route: /]
in SYSTEMPATH/HTTP/CLIRequest.php on line 191.
1 SYSTEMPATH/HTTP/CLIRequest.php(191): array_shift()
2 SYSTEMPATH/HTTP/CLIRequest.php(77): CodeIgniter\HTTP\CLIRequest->parseCommand()
3 SYSTEMPATH/Config/Services.php(148): CodeIgniter\HTTP\CLIRequest->__construct()
4 SYSTEMPATH/Config/BaseService.php(312): CodeIgniter\Config\Services::clirequest()
5 SYSTEMPATH/Config/BaseService.php(251): CodeIgniter\Config\BaseService::__callStatic()
6 SYSTEMPATH/Config/Services.php(143): CodeIgniter\Config\BaseService::getSharedInstance()
7 SYSTEMPATH/Config/BaseService.php(321): CodeIgniter\Config\Services::clirequest()
8 SYSTEMPATH/Config/Services.php(541): CodeIgniter\Config\BaseService::__callStatic()
9 SYSTEMPATH/Config/BaseService.php(321): CodeIgniter\Config\Services::createRequest()
10 SYSTEMPATH/CodeIgniter.php(650): CodeIgniter\Config\BaseService::__callStatic()
11 SYSTEMPATH/CodeIgniter.php(337): CodeIgniter\CodeIgniter->getRequestObject()
12 SYSTEMPATH/Boot.php(325): CodeIgniter\CodeIgniter->run()
13 SYSTEMPATH/Boot.php(67): CodeIgniter\Boot::runCodeIgniter()
14 FCPATH/index.php(56): CodeIgniter\Boot::bootWeb()

The cron command is: 
Code:
php /domain.name/index.php cron eventreminderparticipants
On my localhost it works perfectly. When I run it from the hosting server, I get the above error.
The route is defined as: 
Code:
// cron
$routes->add('cron/eventreminderparticipants', 'Cron::event_reminder_participants');
The beginning of the Cron.php controller is:
Code:
<?php

namespace App\Controllers;

use CodeIgniter\Controller;
use CodeIgniter\HTTP\CLIRequest;
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\RequestInterface;
use CodeIgniter\HTTP\ResponseInterface;
use Psr\Log\LoggerInterface;

/**
* Class Cron
*
* Cron controller is used for cron jobs
*/
class Cron extends Controller
{
    /**
    * Instance of the main Request object.
    *
    * @var CLIRequest|IncomingRequest
    */
    protected $request;

    // cron job name
    protected $name;

    /**
    * @return void
    */
    public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request, $response, $logger);
    }

    // event_reminder_participants --------------------------------------------
    public function event_reminder_participants()
    {
 ...

In the app configuration: 
Code:
public string $indexPage = '';
Could it be that since the server isn't really running a cli command, and the index page is set to empty string, the arguments get mixed up?
I've also tried creating a spark command, but it appears that the request is done via php-cgi, and it won't work.
Please let me know if you have any idea what's happening.
Thank you,
Paul

Writing a Dockerfile: Beginners to Advanced

Strange query behavior CI 4.5.5

$
0
0
I'm running this query with the query builder

PHP Code:
$modifiche_precedenti $this->db->table('modifiche_movimenti')
                ->select('prodotti_modifiche_movimenti.id_prodotto,
                          prodotti_modifiche_movimenti.quantita,
                          prodotti_modifiche_movimenti.operazione,
                          seriali_prodotti_magazzini_in_arrivo.n_seriale'
)
                ->join('prodotti_modifiche_movimenti''modifiche_movimenti.id = prodotti_modifiche_movimenti.id_modifica''left')
                ->join('seriali_prodotti_magazzini_in_arrivo''prodotti_modifiche_movimenti.id_modifica = seriali_prodotti_magazzini_in_arrivo.id_modifica
                                                                AND seriali_prodotti_magazzini_in_arrivo.anno = ' 
$anno_precedente'left')
                ->where('modifiche_movimenti.id_movimento'$id_movimento)
                ->where('modifiche_movimenti.anno'$anno_precedente)
                ->get()
                ->getResultArray(); 

But it gives me the value of n_seriale equal to NULL

I had the executed query printed in the log which is like this


Code:
SELECT
`prodotti_modifiche_movimenti`.`id_prodotto`,
`prodotti_modifiche_movimenti`.`quantita`,
`prodotti_modifiche_movimenti`.`operazione`,
`seriali_prodotti_magazzini_in_arrivo`.`n_seriale`

FROM `modifiche_movimenti`

LEFT JOIN `prodotti_modifiche_movimenti`
ON `modifiche_movimenti`.`id` = `prodotti_modifiche_movimenti`.`id_modifica`

LEFT JOIN `seriali_prodotti_magazzini_in_arrivo`
ON `prodotti_modifiche_movimenti`.`id_modifica` = `seriali_prodotti_magazzini_in_arrivo`.`id_modifica`
AND `seriali_prodotti_magazzini_in_arrivo`.`anno` = 2024

WHERE `modifiche_movimenti`.`id_movimento` = 1

AND `modifiche_movimenti`.`anno` = 2024
And it is correct, but the expected result is not

So I took the query printed in the log and ran it in phpMyAdmin and the result is the expected one, the value of n_seriale is no longer NULL but the value I expected

Why does this happen?

Question mark in redirect url - Google Access Token

$
0
0
Google via its API, to manage the Access Token or Authorization code for updating the token itself, redirects to a url with an intermediate code via composition:
Code:
?code=a/Lor3mIpsumD0l0r-FUCZBl4hDas47Yhd0l39hFnSITbn_GmmDh3w

How to set the Route.php file to read the contents of the variable “code”?

PHP Code:
$routes->get('callback/(:any)', .......); 

doesn't work, returns 404.

Any suggestions?

Case-insensitive routing

$
0
0
Hello,


I’m currently migrating a website from CI 3 to CI 4.

The original developer didn’t follow good naming conventions, so every page has a c_ prefix with inconsistent casing.

I’ve created all routes in lowercase, but for legacy reasons, they need to be case-insensitive.

After some research, I found that CI is case-sensitive by default. However, this can be changed by modifying the checkRoutes method in system/Router/Router.php, setting both $uri and $routeKey to lowercase after the if (str_contains($routeKey, '{locale}')) condition.

Since I don’t want to modify the internal CI codebase due to using Composer and for update reasons, I’m looking for alternative solutions to achieve this.

Codeigniter Shield creates strange tables

$
0
0
Hi, I just created my first project in CodeIgnitier 4. I've been programming with Codeigniter 3 for 8 years. In the Codeigniter Shield documentation, it says that when you run
Code:
php spark shield:setup
, it creates the tables: ‘users’, ‘auth_identities’, ‘auth_logins’, ‘auth_token_logins’, ‘auth_remember_tokens’, ‘auth_groups_users’ and ‘auth_permissions_users’.

However, it creates me: ‘groups’, ‘login_attempts’, ‘migrations’, ‘users’ and ‘users_groups’.

What is going on, which one is correct?

Shield: group controller filter

$
0
0
I want to restrict almost all pages (except login, registration etc) depending on a users group.
In the guide, https://shield.codeigniter.com/reference...r_filters/,  it says: "group: Checks if the user is in one of the groups passed in."
How do I pass in groups to the filter in Config/Filters $globals?

incompatible with DateTimeImmutable

$
0
0
Hi,

i trie to setup/install codeigniter4, for the moment i recieved this error.

"Fatal error: Declaration of CodeIgniter\I18n\TimeTrait::createFromTimestamp(int $timestamp, $timezone = null, ?string $locale = null) must be compatible with DateTimeImmutable::createFromTimestamp(int|float $timestamp): CodeIgniter\Autoloader\Autoloader in /var/www/vhosts/hosting116540.a2f7e.netcup.net/v2.4u.tools/httpdocs/system/I18n/TimeTrait.php on line 268"

What i have to do?

Hiring: CodeIgniter Developer for Large-Scale Web Application

$
0
0
prime42 is looking to hire a full-stack web developer with advanced CodeIgniter skills for On-site or Remote help with a large, CodeIgniter web based application. The project has both a public facing portion as well as an extensive administrative backend with data entry, reporting and billing functions.

Brief overview of some functions that developer will perform:
    • Collaborate with lead developer to maintain and enhance a large CodeIgniter web application.
    • Write clean, maintainable, and scalable PHP/CodeIgniter code following established practices and structure.
    • Suggest changes to existing code to better follow industry best practices as necessary.
    • Implement new features and modules based on project requirements.
    • Support existing features and modules based on project requirements and client changes.
    • Debug, troubleshoot, and optimize existing code for better performance and reliability.

Some of the skills we are looking for:
    • Advanced knowledge of PHP and the CodeIgniter framework.
    • Experience with front-end technologies (HTML5, CSS3, JavaScript, jQuery preferred).
    • Strong database knowledge (MySQL/MariaDB preferred).
    • Familiarity with RESTful APIs and third-party integrations.
    • Version control experience (Git).
    • Strong problem-solving skills and attention to detail.
    • Excellent communication and collaboration abilities.
    • Ability to adapt to changing project requirements.

How to Apply:
Send your resume, portfolio, salary requirements and a brief cover letter to applications@prime42.net. Include examples of past CodeIgniter or PHP projects references from past clients/employers.

About prime42:
prime42, based out of Redding, California, is a website design, hosting and marketing firm with extensive knowledge in all things web related. prime42’s owners have over 40 years combined experience in the industry with diverse backgrounds that add to their ability to problem solve complex technological issues.

PHP 8.4.1. This release marks the latest minor release of the PHP language.

What's new in php 8.4

$
0
0
PHP 8.4 Released!

PHP 8.4 is a major update of the PHP language.
It contains many new features, such as property hooks, asymmetric visibility,
an updated DOM API, performance improvements, bug fixes, and general cleanup.


What's new in PHP 8.4

Starter questions

$
0
0
Hello,

I have now uploaded Codeigniter to the “httpdocs” folder on my web hosting for the first time.
In the browser I now see mydomain.de/public, the welcome page.

Now when I change the web hosting settings for the domain root to “httpdocs/public” I get this error

“Warning: require(): open_basedir restriction in effect. File(/var/www/vhosts/mydomain/subdomain/httpdocs/app/Config/Paths.php) is not within the allowed paths:"

What is the best way to solve this problem to get Codeigniter directly under the domain root without the "public" folder?


By the way, a second question. Is there a standard package that includes user registration for example?


Thanks!

Is kenjis doing okay?

$
0
0
It seems like he’s no longer active in development. Does anyone here know him personally? Is he doing well? I hope he’s alright. He was such a great asset to the community. We miss you, man. Sad

Big thanks for everything you’ve done. Smile

database sqlsrv : add connection info "language"

$
0
0
Hello everyone, my app work with several databases, mysql (windows), mariadb (linux) and mssql (windows). 
I can connect to sql server database but I need to connect it with the connection info "Language"=>"English" to prevent to have different formats of date to manage in my request.
The only solution I found is to modify the file vendor/codeigniter4/framework/system/Database/SQLSRV/Connection.php (method connect )
PHP Code:
        $connection = [
            'UID'                  => empty($this->username) ? '' $this->username,
            'PWD'                  => empty($this->password) ? '' $this->password,
            'Database'            => $this->database,
            'ConnectionPooling'    => $persistent 0,
            'CharacterSet'        => $charset,
            'Encrypt'              => $this->encrypt === true 0,
            'ReturnDatesAsStrings' => 1,
            'Language'=>'English',
        ]; 
This solution is not persistent with futur updates of codeigniter.
Is there a better way to connect with this extra parameter ?
In advance, thank you.

No me genera los documentos PDF en el navegador

$
0
0
Buenos días, estoy realizando un pequeño sistema con CI4, en realidad estoy aprendiendo este esta versión ya que e realizado varios sistema en la versión 3 de CI pero quiero migrar esos sistemas a CI4, mi problema es que cuando trato de generar un documento PDF con algún listado, ya sea de productos, clientes o usuarios, no los genera en el navegador, solo me muestra en una nueva pestaña, una seria de caracteres especiales y mas nada, si le coloco al código para que los descargue directamente a la PC, si lo hace perfecto, el problema esta al querer generarlo en el navegador. No se si será alguna extensión de PHP que se debe activar. Si me pueden ayudar con este inconveniente se los agradezco. Gracias

Spark Fatal error: Uncaught Error: Call to undefined function str_starts_with()

$
0
0
Hi,

i trie to setup my codeigniter framework with shield. For that i think i have finaly setup shield with this command "php spark shieldConfusedetup"

After typing this command in putty, i recieved this message:

"php spark
Fatal error: Uncaught Error: Call to undefined function str_starts_with() in /v2.4u.tools/httpdocs/spark:28
Stack trace:
#0 {main}
  thrown in /my_domain/httpdocs/spark on line 28"

What I doing wrong?

Issue with site_url() after upgrade to 4.5.5

$
0
0
Upgraded my site from 4.3.8 to 4.5.5 this morning. I have gone through all the changes version by version and have the site basically running again. One issue that has me completely stopped is the behavior of site_url(). I know there were breaking changes around 4.4, but I can't for the life of me see how they apply in this case. What I have...
In my .env file:
PHP Code:
app.baseURL 'https://domain.com/'

app.indexPage '' 


In my view file:
PHP Code:
<class="nav-link" href="<?= site_url() ?>" target="_blank"


In 4.3.8 (and before) this returned:
PHP Code:
<class="nav-link" href="https://domain.com" target="_blank"


In 4.5.5 it is returning:
PHP Code:
<class="nav-link" href="" target="_blank"

If I put a value in:
PHP Code:
app.indexPage 'index' 

I get (in 4.5.5):
PHP Code:
<class="nav-link" href="https://index/index" target="_blank"
If I use the example from the docs (with the original .env file settings):
PHP Code:
<class="nav-link" href="<?= site_url('news/local/123'); ?>" target="_blank"

I get:
PHP Code:
<class="nav-link" href="https://news/news/local/123" target="_blank"


Is there a setting somewhere I missed during the upgrades? Am I missing something obvious in the docs?
Help!
Viewing all 14136 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>