Welcome Guest, Not a member yet? Register   Sign In
  Getting supportedLocales after upgrade to 4.5.1
Posted by: kcs - Today, 08:23 AM - Replies (2)

Hi everyone,
I am using https://includebeer.com/en/blog/creating...r-4-part-1 for localization and after upgrading to 4.5.1, I am getting this error: 

Code:
Cannot access protected property CodeIgniter\HTTP\IncomingRequest::$config

APPPATH/Controllers/BaseController.php at line 61

60        $this->viewData['locale'] = $request->getLocale();
61        $this->viewData['supportedLocales'] = $request->config->supportedLocales;

Looking at the documentation, I tried to replace the call with
Code:
$this->viewData['supportedLocales'] = config('supportedLocales');
I don't get the error anymore, but when I want to display the navigation elements and call $supportedLocales inside my view, It is NULL so I am not doing the right thing.

Can anyone help me?


  Pipe on url modified in %
Posted by: pippuccio76 - Today, 07:37 AM - Replies (3)

I , in my url i want send string with pipe (redirect with data) this is data in url :

15%7CA%7C2514%7CH.3.001%7C3%7CBM-FASE10

| are transform into %7C , how can i send pipe without transform?


  extend url_to helper
Posted by: sjender - Today, 07:01 AM - Replies (2)

Hi,
I would like to extend the url_to() helper function.
This is what I did...

PHP Code:
<?php

use CodeIgniter\Router\Exceptions\RouterException;

function 
url_to(string $controller, ...$args): string
{
    if(empty($_GET['ref'])){
        return original_url_to($controller, ...$args);
    }

    /* EXTRA CODE */
}

//This is a copy of the original CI4 url_to function
function original_url_to(string $controller, ...$args): string
{
    if(!$route route_to($controller, ...$args)){
        $explode explode('::'$controller);

        if(isset($explode[1])){
            throw RouterException::forControllerNotFound($explode[0], $explode[1]);
        }

        throw RouterException::forInvalidRoute($controller);
    }

    return site_url($route);


But I would prefer I didn't have to make a copy of the original function, but refer directly to the CI4 function instead,
How can do this?


  How to use Codeigniter with other framework?
Posted by: sr13579 - Today, 02:17 AM - Replies (2)

I would like to use the database classes and methods in other PHP frameworks. I have an idea if I include the autolader from vendor it will work, but I can't find a tutorial about that. Could anyone please help me?


Question External script access to return html data
Posted by: ezydev - Yesterday, 11:41 PM - No Replies

Good Day,

I have an existing report engine within a codeigniter webpage environment. The report engine is quite simple, it has a drop down of different reports which can be run and date ranges that can be filled in. When submitting, a reportPresenter.js file handles the submit action which then renders the selected report, which basically loads it's respective js loader i.e. customerReport.js which has a Datatables builder which returns a formatted report. It works perfectly when using manually, but I would now like to try and schedule some of these reports to be sent weekly via email to certain addresses. I'd like to avoid having to rebuild the entire report, as the one I'm wanting to schedule is very complex, so replicating the functionality is quite tricky, as well as it would require me to update 2 separate files whenever I need to make any sort of changes to the reports.

I've explored a solution which is feasible when working outside of a codeigniter framework, which is basically a curl approach in php to load the respective url for the report area, capture the original html, then input the selected report and dates through code, these can be hard coded, and then triggering the submit button from the php code, after which we then curl the url again, capture only the report-table <table> element and extract that out of the rest and then construct that HTML into a pdf report and attach it to the email. This works perfectly in non-restrictive environments like simple html pages, etc. However as soon as I try it in codeigniter, I get met with the regular login page which is there for security purposes. I've tried posting login credentials to the login URL in order to access the reports url, but no matter how I post the credentials through a curl request, it seems to just return an empty string as a response. I'm not too familiar with how the codeigniter environments are setup but I do understand that I likely need either some kind of API key, or session key after logging in, in order to access data past the login page, however I can't seem to find any resources that can assist me with doing this (if it is even possible).

Hoping someone who might have done something similar might be able to share their suggestions, my main aim is to basically generate a report for a certain period and then schedule this to be run through my cronjob scheduler, without having to build an entire new engine to run this.


  Limiting Stack Trace Error on log file for certain scenarios
Posted by: byrallier - Yesterday, 04:41 PM - Replies (2)

Hello,

I have a PHP file runs for hours (like cronjob), sometimes it logs exceptions (its handled but logged to log file) due to SQL deadlocks.

But I couldn't manage to limit string of error log for stack trace that dumped to log file.



To clarify it more here is a sample workflow:





PHP Code:
<?php
function inserter($counter=0){
 while (true) {
try:
  do some SQL inserts for 1000 times
catch:
log_message('error','excepton 502:' sizelimit($e->getMessage().$trace,1000).'\n');
 }
 $counter++;
 if($counter<1000)
   inserter($counter)
}
?>


as you can see above this is a long running script and it call itselfs, when something goes wrong (its accepted) it logs an error message but my problem is not with my error message. Also it logs a full stack trace by CodeIgniter framework and I couldnt find a way to limit its log. Because while this script is running multiple times, it creates a huge stack trace like:


---------------------------------
ERROR - 2024-04-21 22:24:07 --> ErrorException: pg_query(): Query failed: ERROR:  canceling statement due to statement timeout
CONTEXT:  while scanning relation "public.datas_meta" in /codeigniterphp/appsrc/system/Database/Postgre/Connection.php:187
Stack trace:
#0 [internal function]: CodeIgniter\Debug\Exceptions->errorHandler(2, 'pg_query(): Que...', '/codeigniterphp/appsrc/sy...', 187)
#1 /codeigniterphp/appsrc/system/Database/Postgre/Connection.php(187): pg_query(Object(PgSql\Connection), ' VACUUM (VERBOS...')
#2 /codeigniterphp/appsrc/system/Database/BaseConnection.php(693): CodeIgniter\Database\Postgre\Connection->execute(' VACUUM (VERBOS...')
#3 /codeigniterphp/appsrc/system/Database/BaseConnection.php(607): CodeIgniter\Database\BaseConnection->simpleQuery(' VACUUM (VERBOS...')
#4 /codeigniterphp/appsrc/app/Controllers/MyController.php(1309): CodeIgniter\Database\BaseConnection->query(' VACUUM (VERBOS...')
#5 /codeigniterphp/appsrc/app/Controllers/MyController.php(164): App\Controllers\MyController->pg_vacuum_tables(0, 1713737945.7492)
#6 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#7 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#8 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#9 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#10 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#11 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#12 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#13 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#14 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#15 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#16 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#17 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#18 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#19 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#20 /codeigniterphp/appsrc/app/Controllers/MyController.php(271): App\Controllers\MyController->inserter()
#21 /codeigniterphp/appsrc/app/Controllers/MyController .....
....
...
#1000  /codeigniterphp/appsrc/app/Controllers/MyController


---------------------------------

I want to limit total size of dump for a single log message, is there a way to do it or just I have to change play with CI's source code? I didnt want to do it on CI's source code at first intention due to I am happy to migrate new version of it easily, otherwise it increases my anxiety Smile)

happy to get your ideas.


Question Best way to create microservices projects with CodeIgniter 4
Posted by: jean5769 - Yesterday, 01:51 PM - Replies (6)

Hello ! Is there a good way to create multiple microservices projects using CodeIgniter 4? I see every where that Symfony is a good framework to do this, but I prefer to use CodeIgniter 4! Thanks Big Grin


  Version number stays un-updated in toolbar
Posted by: trunky - 04-19-2024, 04:12 PM - No Replies

Hi,
strange problem (for me at least). I've want to update a project running on CI 4.4.6 to 4.4.8 or 4.5.1 and noticed that it shows 4.4.0 in the toolbar, though 4.4.6 is installed.
I've tried downgrading to 4.4.0 and retry the steps update to 4.4.1 again, did not help. I also tried to upgrade to 4.5.1 which did not work right ahead but gave me a strange error message about Config/Filters need to be an array. I suspect it comes from (missing?) updates before as the Config/Filters.php is the same as stock CI. At least in the error message was 4.5.1 listed Smile
Long story short, where does the version number come from? So I can try to get it updated properly from 4.4.0 onwards.


  Depractaion request warning
Posted by: chxgbx - 04-19-2024, 05:52 AM - Replies (2)

I am queite new to codeigniter and having some issues with the request object.

I am trying to pass some tokens from before filter to the request object but getting some depracation warning when trying to access it from controller

```
// before filter
$request->decodedToken = $decoded;
```
```
// after filter
   public function logout()
   {
       $originalToken = $this->request->originalToken ?? null;
   }

```

WARNING - 2024-04-19 12:40:09 --> [DEPRECATED] Creation of dynamic property CodeIgniter\HTTP\IncomingRequest::$originalToken is deprecated in APPPATH/Filters/AuthFilter.php


  Type error in SYSTEMPATH\View\Cells\Cell.php at line 88
Posted by: DXArc - 04-19-2024, 04:08 AM - Replies (3)

I got a type error in SYSTEMPATH\View\Cells\Cell.php at line 88:
substr(): Argument #3 ($length) must be of type ?int, bool given
because of
declare(strict_types=1);
I changed the code to:
            $pos = strrpos($viewName, '_cell');
            if ($pos === false) {
              $possibleView1 = $directory . $viewName . '.php';             
            } else {
              $possibleView1 = $directory . substr($viewName, 0, $pos) . '.php';
            }

Now the gallery using Cell.php is working. I hope it helps.


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

Username
  

Password
  





Latest Threads
Type error in SYSTEMPATH\...
by kenjis
5 hours ago
composer didn't update to...
by Sarog
7 hours ago
Pipe on url modified in %
by kenjis
8 hours ago
Best way to create micros...
by kenjis
8 hours ago
How to use Codeigniter wi...
by kenjis
8 hours ago
extend url_to helper
by kenjis
8 hours ago
Getting supportedLocales ...
by kcs
Today, 08:56 AM
Limiting Stack Trace Erro...
by byrallier
Today, 05:43 AM
External script access to...
by ezydev
Yesterday, 11:41 PM
v4.5.1 Bug Fix Released
by kenjis
Yesterday, 04:59 PM

Forum Statistics
» Members: 84,957
» Latest member: win456biz1
» Forum threads: 77,570
» Forum posts: 375,942

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB