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

PHPExcel Library Not Working with PHP 8.0

$
0
0
I have upgraded my PHP Version to 8.0 and I am using Codeigniter 3, but PHP Excel library is not working with PHP 8.0. Suggest me compatible PHP Excel Library with Codeigniter 3 & PHP 8.0

How to Avoid SQL Injection: A Comprehensive Guide

Cannot disable CI Session handling in v4.5.1

$
0
0
After reading the userguide (excerpt below), I believe this is a bug-:

Quote: Wrote:This was due to the specifics of how sessions worked, but is now no longer necessary with our new implementation. However, it may happen that your application relied on these values, so here are alternative methods of accessing them:

session_id: $session->session_id or session_id() (PHP’s built-in function)


Before v4.3.0, the session configuration was held in Config/App.php. Now Config/Session.php holds the session configuration. There is nothing in Config/Session.php to indicate how to turn off CI session handling. Looking at the CI code appears to confirm this.

How to reproduce:
# Setup new CI v4.5.1 with composer
# In BaseController, add session_start()

PHP Code:
Code:
    public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger)
    {
        // Do Not Edit This Line
        parent::initController($request, $response, $logger);
        session_start();
    }

# Then browse to site's home page. Exception is thrown in FileHandler-:
SYSTEMPATH/Session/Handlers/FileHandler.php at line 74
Code:
Code:
68   public function __construct(SessionConfig $config, string $ipAddress)
69     {
70         parent::__construct($config, $ipAddress);
71
72         if (! empty($this->savePath)) {
73             $this->savePath = rtrim($this->savePath, '/\\');
74             ini_set('session.save_path', $this->savePath);
75         } else {
76             $sessionPath = rtrim(ini_get('session.save_path'), '/\\');
77
78             if ($sessionPath === '') {
79                 $sessionPath = WRITEPATH . 'session';
80             }

best practice: recurring events

$
0
0
Hi everone, 

I administrate events with CI4 and would like to make some of them recurring events.
What is best practice to do that? Would I insert copies of the event for each time to the database? If so, for how many years? Or shall I set active years and if I add a new year I look up all active events and copy them to the full new year?
Are there any tricky ways to manage this? How have you done it? And if you have not done it, have you got a good idea how to do it?

Best, Jan

Machine Learning with PHP (DEV.to)

Can't update 4.4.8 to 4.5.0

$
0
0
So I tried to run composer update to update 4.4.8 to 4.5.0 and got this error. 

PHP Code:
This "system/bootstrap.php" is no longer used. If you are seeing this error messagethe upgrade is not completePlease refer to the upgrade guide and complete the upgradeSee https://codeigniter4.github.io/userguide/installation/upgrade_450.html 

I've made changes to all the files listed in upgrade guides

Custom heading in HTML Table Class

$
0
0
How to achieve something like this in pure html


Code:
<th scope="col" class="text-center">Options</th>
<th scope="col" class="text-center">Deadline</th>
<th scope="col">Topic</th>


As you see last line is different from first two lines. I know there is setHeading(), but dont know how to "custom" one heading with HTML Table Class.

What's new in PHP 8.3


How to create forgot password API using shiled with codeIgnitor 4

$
0
0
Hi
I  am new to codeignitor and using shield for first time. I need to create forgot password API functionality. I searched a lot regarding this, but I got all tutorials without using shield.
I want user to enter their email, if verified email, then user should receive email with password reset link.
User should be able to reset password by clicking on this link, if it's a valid link. 

I am looking for assistance with the issue I mentioned.
Thanks

DotEnv file is better loaded from the index.php

$
0
0
CodeIgniter is by far the most ideal framework that is truly versatile. In some instances, especially for cloud based applications, where many instances will run the same "app" code but with different index.php files and .env files. That flexibility should be retained. 
The current location in the Boot.php file is not so cool, as it will bring sudden limitation to CI4.
Thanks

Login issue on huge traffic

$
0
0
Hi there,

I have an app built using CI3. The login function works but when simultaneously a huge traffic tries to login it fails for some of them. 
Currently I am unaware of why that happens. It happens even though they are using correct credentials. If traffic is less then they are not facing any issues.
My concern is why it fails for only few of them. I am using CI3 query builder to generate query.

How can get Response from API when status is 4xx using Curl library

$
0
0
some API has set 400, 401 etc if have error in username or other param
in CI4 (v4.4.8) I cant get response for this.

any idea?

PHP 8.3.8. This is a security release.

$
0
0
PHP 8.3.8. This is a security release.

PHP fixes critical RCE flaw impacting all versions for Windows

Docker Mastery: A Comprehensive Guide for Beginners and Pros


PHP Spark not picking up environment variable (undefined constant ENVIRONMENT)

$
0
0
Hi,
I am using php spark to bootstrap the tables/database seeding in my codeigniter 4 app, but spark is not recognizing the "ENVIRONMENT" environment variable set by docker-compose.yml. To clarify, my CI4 app is picking up the environment variables, just not spark.
Here is the stack trace from the docker container when I run: php spark
Code:
Fatal error: Uncaught Error: Undefined constant "ENVIRONMENT" in /var/www/html/Tooths/system/Common.php:777
Stack trace:
#0 /var/www/html/Tooths/system/Debug/Exceptions.php(458): log_message('warning', '[DEPRECATED] {m...', Array)
#1 /var/www/html/Tooths/system/Debug/Exceptions.php(216): CodeIgniter\Debug\Exceptions->handleDeprecationError('Creation of dyn...', '/var/www/html/T...', 218)
#2 /var/www/html/Tooths/app/Config/App.php(218): CodeIgniter\Debug\Exceptions->errorHandler(8192, 'Creation of dyn...', '/var/www/html/T...', 218)
#3 /var/www/html/Tooths/system/Config/Factories.php(235): Config\App->__construct()
#4 /var/www/html/Tooths/system/Config/Factories.php(169): CodeIgniter\Config\Factories::createInstance('config', 'Config\\App', Array)
#5 /var/www/html/Tooths/system/Config/Factories.php(188): CodeIgniter\Config\Factories::__callStatic('config', Array)
#6 /var/www/html/Tooths/system/Common.php(207): CodeIgniter\Config\Factories::get('config', 'Config\\App')
#7 /var/www/html/Tooths/system/Config/Services.php(564): config('Config\\App')
#8 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::incomingrequest(NULL, false)
#9 /var/www/html/Tooths/system/Config/Services.php(526): CodeIgniter\Config\BaseService::__callStatic('incomingrequest', Array)
#10 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::request(NULL, false)
#11 /var/www/html/Tooths/system/Config/BaseService.php(250): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#12 /var/www/html/Tooths/system/Config/Services.php(522): CodeIgniter\Config\BaseService::getSharedInstance('request', NULL)
#13 /var/www/html/Tooths/system/Config/BaseService.php(311): CodeIgniter\Config\Services::request()
#14 /var/www/html/Tooths/system/Debug/Exceptions.php(129): CodeIgniter\Config\BaseService::__callStatic('request', Array)
#15 /var/www/html/Tooths/system/Debug/Exceptions.php(252): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException))
#16 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler()
#17 {main}
  thrown in /var/www/html/Tooths/system/Common.php on line 777

Not sure if relevant, but I also found the following output in the logs:

Code:
This "system/bootstrap.php" is no longer used. If you are seeing this error message,
the upgrade is not complete. Please refer to the upgrade guide and complete the upgrade.
See https://codeigniter4.github.io/userguide/installation/upgrade_450.html

Do CodeIgniter 4 model instances already have Query Builder methods loaded?

$
0
0
When I instantiate a model in CodeIgniter 4, does it already have the Query Builder methods loaded, or is there a better way to access them?

localize databases with working searching and ordering?

$
0
0
Hello,

I try to implement an application that can be localized. Text in php and views is no problem, since I can use 'lang()', but now I have a database table that holds colors and their name.

I stored the colors in english (black, blue, green, ...). No problem while just displaying them. I just use "<?= lang('Colors.' . $color->name) ?> in templates and get a localized output (e.g. german: schwarz, blau, grün).

But now I offer the possibility to search and order by color and that leads to wrong (order) or no (search) results, since e.g. order

In english:
  • green
  • black
  • blue
In german:
  • blau (blue)
  • grün (green)
  • schwarz (black)
Searching is broken at all, since names are complete different. Any ideas how to solve this except with this construction that may get really long (usually I prefer query builder, but there is no CASE support):

Code:
$db->query('
  select case
    when name = "Colors.black" then "' . lang('Color.black' . '"
    when name = "Colors.green" then "' . lang('Color.green' . '"
    ...
  end as color_name from colors order by color_name');

results in:
Code:
$db->query('
  select case
    when name = "Colors.black" then "schwarz"
    when name = "Colors.green" then "grün"
    ...
  end as color_name from colors order by color_name');
Any ideas to make it better? Unfurtunatelly there is no reverse_lang(), so that I could simply translate the localized string, back to its placeholder.

v4.5.2 bug fix

unstable new 4.5.1 installation

$
0
0
I've downloaded the new version - the usual procedure: not working.

So I have several subdomains and start with the original 4.5.1 files: working fine. Then I add my controllers etc. and check manually where problems appear.

the debug bar is not working in http subdomains. The JS is located at mydomain.com/index.php?debugbar.js - but there is no index.php also an error in console is displayed:
Refused to execute as script because "X-Content-Type-Options: nosniff" was given and its Content-Type is not a script MIME type. the x-content-type deleted in htaccess

in one subdomain my files work, if CI_ENVIRONMENT = development is not set in the .env - otherwise the screen is just white.

in the other subdomain I get an Exception #403 error. no matter that the files are the same as in the other subdomains.

and in the third subdomain everything works fine - except the debug bar.

in one main https subdomain, everything works perfect

I'm working for two decades with CI and toying around with each new version is quite annoying.

how can I use the debugbar in non https subdomains?
how can the development environment stop the site from working?

Hope there are some hints.

Thank you in advance
Viewing all 14348 articles
Browse latest View live


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