Welcome Guest, Not a member yet? Register   Sign In
  fatal logger emergency
Posted by: badger - 05-13-2024, 04:16 AM - Replies (5)

a clean install of 4.5.1 runs perfectly on my local system but when i copy it to the remote it crashes immediately. both systems are using php8.1
a similar application running on the same host but using 4.3.3 runs perfectly

PHP Code:
Fatal errorDeclaration of CodeIgniter\Log\Logger::emergency(Stringable|string $message, array $context = []): void must be compatible with PsrExt\Log\LoggerInterface::emergency($message, array $context = []) in /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Log/Logger.php on line 162

Fatal error
Uncaught Error: Class "CodeIgniter\Log\Logger" not found in /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/Services.php:403 Stack trace#0 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/BaseService.php(311): CodeIgniter\Config\Services::logger(false) #1 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/BaseService.php(250): CodeIgniter\Config\BaseService::__callStatic('logger', Array) #2 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/Services.php(400): CodeIgniter\Config\BaseService::getSharedInstance('logger') #3 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/BaseService.php(311): CodeIgniter\Config\Services::logger() #4 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/BaseService.php(201): CodeIgniter\Config\BaseService::__callStatic('logger', Array) #5 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Common.php(998): CodeIgniter\Config\BaseService::get('logger') #6 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Common.php(785): service('logger') #7 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Debug/Exceptions.php(140): log_message('critical', 'ErrorException:...', Array) #8 /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Debug/Exceptions.php(252): CodeIgniter\Debug\Exceptions->exceptionHandler(Object(ErrorException)) #9 [internal function]: CodeIgniter\Debug\Exceptions->shutdownHandler() #10 {main} thrown in /var/www/vhosts/53/149679/webspace/siteapps/vendor/codeigniter4/framework/system/Config/Services.php on line 403 

many thnaks for any help, Bill


  SIngle quote on model save
Posted by: pippuccio76 - 05-13-2024, 12:48 AM - Replies (4)

Hi this is a simple part of my code :

Code:
                $post = $this->request->getPost();


                $res=$users_model->save($post);
I have some surname with singol quote and in db is not inserted the part after single quote , why ?


  Error 500 Internal Server Error after update to 4.5.1
Posted by: shafiei777 - 05-12-2024, 09:51 PM - Replies (2)

Hello,
After I updated CI 4.4.6 to 4.5.1 , some API functions encounter error "503 Internal Server Error", but other functions run correctly.

Regards,


  Transactions
Posted by: sunchaser - 05-11-2024, 12:03 PM - No Replies

Hello, i would like to run some sql statements but, if there is any exception (not only Database Exception, but any exception like out of memory etc) i want the sql statements rolled back. 
I have a mysql database with all the tables on INNODB engine.
I made this code:

PHP Code:
$db = \Config\Database::connect();
 
$db->transBegin();

try { 
    $rc $model->execute(array($structure_id));
    $db->transCommit();
}
catch (\
Exception $e)
{
    $db->transRollback();
    log_message('debug''Exception: ' $e->getMessage());


In the function execute I am throwing an exception but the sql is commited and not rolled back. What am I doing wrong?

Thanks


  Converting a CI3 Project to CI4.5.1
Posted by: Josh1985 - 05-10-2024, 07:30 PM - Replies (7)

Hello all!

I have recently sat down with the intention of converting a pretty large CI3 project into CI4. However, I have ran into a few issues that I can't seem to find in the documentation that really specifies what to do in my situation.

Library Conversions:

MyController.php (Custom Controller Library)

PHP Code:
<?php

 
class MyController extends CI_Controller{
  function __construct(){
  parent::__construct();
  $this->load->vars(array('toc' => $this->recipe_model->read_names_categories(),
  'admin_menu_items' => array(),
  'admin' => $this->is_logged_in()));
  if($this->is_logged_in()){
    date_default_timezone_set($this->session->userdata('tz'));
  }
  else{  // If the IF statement returns false, then  the ELSE statement tells php to do something else.
    date_default_timezone_set('America/New_York');
  }
  }
    
  
function is_logged_in(){
  $logged_in $this->session->userdata('logged_in');
  if(isset($logged_in) && $logged_in){
    return true;
  }
  else{  // If the IF statement returns false, then  the ELSE statement tells php to do something else.
    return false;
  }
  }
    
  
function require_login(){
  if(!$this->is_logged_in()){
    redirect('login');
  }
  }
    
  
function format_date($datestr){
  //date_default_timezone_set('UTC');
  $date strtotime($datestr.' UTC');
  //date_default_timezone_set('America/New_York');
  $datestr date("n/j/Y @ g:i A T"$date);
  return $datestr;
  }  
 
}  
 
 
// End of MyController CUSTOM Controller.php
 // End of MyController.php

?>

MySecurity.php (Custom Security Library)
PHP Code:
<?php

 
class MySecurity extends CI_Security {
  
  
/*
  * CSRF Set Cookie with samesite
  *
  * @codeCoverageIgnore
  * @return  CI_Security
  */
  
  
public function csrf_set_cookie(){
  $expire time() + $this->_csrf_expire;
  $secure_cookie = (bool) config_item('cookie_secure');
  if($secure_cookie && ! is_https()){
    return FALSE;
  }
  setcookie($this->_csrf_cookie_name,
            $this->_csrf_hash,
            ['samesite' => 'Strict',
              'secure'  => true,
              'expires'  => $expire,
              'path'    => config_item('cookie_path'),
              'domain'  => config_item('cookie_domain'),
              'httponly' => config_item('cookie_httponly')]);
              
  log_message
('info''CSRF cookie sent');
  return $this;
  }
 }

 
// End of MySecurity CUSTOM Security.php
 // End of MySecurity.php

?>

1. In CI3, this current project had several different custom libraries in use in CI3's application/core, CI3's application/libraries, and CI3's system/libraries directories. My question is here in CI4, I only see one "Libraries" directory in app/Libraries. Is this one location where ALL of my libraries would go? Or do I need to divide them between this directory and put others somewhere else?

2. In CI3, this project had a custom controller and a custom security exception.  So, again where would these files go?

3. I know in CI4, we often use BaseController as our extendable controller base class. The custom controller from CI3 that I am referring to was basically doing something very similar to what the BaseController class does in CI4. So my issue is, do I just add the custom parameters to BaseController or do I add the custom controller class into some special directory?   

Any help would be greatly appreciated!

Thanks


  File not found on my online server
Posted by: Kobbs - 05-10-2024, 11:33 AM - Replies (10)

Hi, I've been trying to solve my problem all day but I haven't been able to solve it. Locally, my site works fine when I browse it. But on my online server, when I try to access the mywebsite.com/test page it gives me this error: File not found.

Routes.php

PHP Code:
<?php

use CodeIgniter\Router\RouteCollection;

/**
* @var RouteCollection $routes
*/
$routes->get('/''Home::index');
$routes->get('test''Home::mytest'); 

Home.php

PHP Code:
<?php

namespace App\Controllers;

class 
Home extends BaseController
{
    public function 
index(): string
    
{
        return 
view('welcome_message');
    }

    public function 
mytest()
    {
        echo 
"test...";
    }



All my files (app, public, tests, vendor, writable, etc.) are in the root of my server in the ‘www’ folder.

Thank you in advance for your help.


Question Validation error messages keep being loaded from system
Posted by: kabeza - 05-10-2024, 05:59 AM - Replies (5)

Hi
I'm trying to translate the error messages from Validation service:

I've set in app/Config/App.php

Code:
public string $defaultLocale = 'es';

public array $supportedLocales = ['en', 'es'];

I've also created (as stated in userguide) the folder and file

Code:
app/Language/es/Validation.php

But the error messages keep being loaded from vendor/codeigniter4/framework/system/Language/en/Validation.php (I've confirmed this by changing strings there and trying again)

Am I ignoring anything else?


  CodeIgniter4 - How i can add extra 3 fields to a created table using Migration ?
Posted by: sarath_unrelax - 05-10-2024, 05:08 AM - Replies (2)

Dear Everyone,

I'm a beginner to CI4, I created a table with 10+ fields using migration file, after reviewing my management, they want me to add extra 4 fields on it. So I should create a new migration fille seperate for each field or i can just create a migration file using below command ?

Code:
php spark make:migration AddExtraFieldsToEmployeesTable
After i can use addField() command in up() and removeFiled() in down() ?

This is correct way ?


  How to Find & Hire Codeigniter Developers in 2024
Posted by: php_rocs - 05-09-2024, 06:52 AM - Replies (3)

An encouraging and interesting read. https://www.developersforhire.com/codeigniter


  6 hard truths about learning to code in 2024 (DEV.TO)
Posted by: php_rocs - 05-09-2024, 06:27 AM - Replies (2)

True indeed. https://dev.to/educative/6-hard-truths-a...n-2024-ppj


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

Username
  

Password
  





Latest Threads
Call multiple function in...
by warcooft
11 minutes ago
Call to undefined functio...
by nanohe
2 hours ago
Query Builder Conditions ...
by kenjis
3 hours ago
Create a copy of file fro...
by Ege
8 hours ago
how to use set_select on ...
by kcs
11 hours ago
How to use Amazon PHP SDK...
by asimeou
Yesterday, 10:53 AM
fatal logger emergency
by kenjis
Yesterday, 03:39 AM
Array to HTML "Table"
by Bosborne
Yesterday, 03:28 AM
Insert Batch Using Entity...
by warcooft
Yesterday, 02:48 AM
SIngle quote on model sav...
by kenjis
05-13-2024, 11:30 PM

Forum Statistics
» Members: 87,640
» Latest member: bongvipbar
» Forum threads: 77,648
» Forum posts: 376,389

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB