Let's Share your experience!!!

Close (X)

Sunday, April 26, 2020

Apa yang harus dilakukan saat upload web aplikasi pada Server dengan menggunakan CodeIgniter (CI)

Dalam membuat sebuah sistem informasi dibutuhkan skill dan logika yang mumpuni. Setidaknya memahami dalam setiap masalah yang ada seperti dalam aplikasi berbasis web dengan CodeIgniter. Pernahkah anda memiliki hasil tampilan seperti ini:




A PHP Error was encountered

Severity: Warning
Message: is_dir(): open_basedir restriction in effect. File(/opt/alt/php72/var/lib/php/session) is not within the allowed path(s): (/home/webiotid/:/tmp:/var/tmp:/opt/alt/php71/usr/share/pear/:/dev/urandom:/usr/local/lib/php/:/usr/local/php71/lib/php/)
Filename: drivers/Session_files_driver.php
Line Number: 134
Backtrace:
File: /home/webiotid/domains/webiot.id/public_html/link/application/controllers/Main.php
Line: 8
Function: __construct
File: /home/webiotid/domains/webiot.id/public_html/link/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning
Message: mkdir(): open_basedir restriction in effect. File(/opt/alt/php72/var/lib/php/session) is not within the allowed path(s): (/home/webiotid/:/tmp:/var/tmp:/opt/alt/php71/usr/share/pear/:/dev/urandom:/usr/local/lib/php/:/usr/local/php71/lib/php/)
Filename: drivers/Session_files_driver.php
Line Number: 136
Backtrace:
File: /home/webiotid/domains/webiot.id/public_html/link/application/controllers/Main.php
Line: 8
Function: __construct
File: /home/webiotid/domains/webiot.id/public_html/link/index.php
Line: 315
Function: require_once

An uncaught Exception was encountered

Type: Exception
Message: Session: Configured save path '/opt/alt/php72/var/lib/php/session' is not a directory, doesn't exist or cannot be created.
Filename: /home/webiotid/domains/webiot.id/public_html/link/system/libraries/Session/drivers/Session_files_driver.php
Line Number: 138
Backtrace:
File: /home/webiotid/domains/webiot.id/public_html/link/application/controllers/Main.php
Line: 8
Function: __construct
File: /home/webiotid/domains/webiot.id/public_html/link/index.php
Line: 315
Function: require_once

Lalu bagaimana cara mengatasi masalah ini,

Bagaimana cara untuk membedakan CodeIgneter atau CI di locahost dan server atau hosting,

Jika ada masalah seperi di atas, maka lakukan perubahan Config pada Folder Application/config/config.php.
Jika menggunakan localhost, maka cari dan gunakan kode berikut:



$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
//$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;


Jika menggunakan server atau hosting, maka cari dan gunakan kode berikut:



$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
//$config['sess_save_path'] = NULL;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;




Masih banyak masalah lainnya. Seperti

A PHP Error was encountered

Severity: Runtime Notice
Message: Only variables should be passed by reference
Filename: controllers/Main.php
Line Number: 58
Backtrace:
File: F:\xampp\htdocs\yourApp\application\controllers\Main.php
Line: 58
Function: _error_handler
File: F:\xampp\htdocs\yourApp\index.php
Line: 315
Function: require_once

Fatal error: Maximum execution time of 30 seconds exceeded in F:\xampp\htdocs\yourApp\system\database\drivers\mysqli\mysqli_driver.php on line 305

A PHP Error was encountered

Severity: Error
Message: Maximum execution time of 30 seconds exceeded
Filename: mysqli/mysqli_driver.php
Line Number: 305
Backtrace:


Pemecahan masalahnya adalah sebagai berikut:



<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Main extends CI_Controller
{
 function __construct()
 {
     parent::__construct();
     setlocale(LC_TIME, "");
.................................................
         ini_set('max_execution_time', 0); 
         ini_set('memory_limit','2048M');
 }



Kode ini ditambahkan pada Controller yang ingin diberikan tambahan waktu upload file
         ini_set('max_execution_time', 0);
        ini_set('memory_limit','2048M');


Kesalahan lain:


Warning: Declaration of ActiveRecord\DateTime::setTime($hour, $minute, $second = NULL) should be compatible with DateTime::setTime($hour, $minute, $second = NULL, $microseconds = NULL) in F:\xampp7\htdocs\project\vendor\php-activerecord\php-activerecord\lib\DateTime.php on line 139

Pemecahan masalah:
ganti file dengan https://github.com/jpfuentes2/php-activerecord/blob/master/lib/DateTime.php
hilangkan  implements DateTimeInterface pada baris 36 yaitu:
class DateTime extends \DateTime

Warning: Class 'Former\Facades\Former' not found in F:\xampp7\htdocs\project\application\config\config.php on line 85

A PHP Error was encountered

Severity: 8192
Message: implode(): Passing glue string after array is deprecated. Swap the parameters
Filename: php-activerecord/ActiveRecord.php
Line Number: 41
Backtrace:
File: F:\xampp7\htdocs\project\vendor\php-activerecord\php-activerecord\ActiveRecord.php
Line: 41
Function: implode
File: F:\xampp7\htdocs\project\application\config\config.php
Line: 85
Function: class_alias
File: F:\xampp7\htdocs\project\index.php
Line: 283
Function: require_once

A PHP Error was encountered

Severity: 8192
Message: implode(): Passing glue string after array is deprecated. Swap the parameters
Filename: php-activerecord/ActiveRecord.php
Line Number: 41
Backtrace:
File: F:\xampp7\htdocs\project\vendor\php-activerecord\php-activerecord\ActiveRecord.php
Line: 41
Function: implode
File: F:\xampp7\htdocs\project\vendor\anahkiasen\former\src\Former\Facades\Former.php
Line: 10
Function: spl_autoload_call
File: F:\xampp7\htdocs\project\vendor\composer\ClassLoader.php
Line: 378
Function: include
File: F:\xampp7\htdocs\project\vendor\composer\ClassLoader.php
Line: 270
Function: Composer\Autoload\includeFile
File: F:\xampp7\htdocs\project\application\config\config.php
Line: 85
Function: class_alias
File: F:\xampp7\htdocs\project\index.php
Line: 283
Function: require_once

A PHP Error was encountered

Severity: 8192
Message: implode(): Passing glue string after array is deprecated. Swap the parameters
Filename: php-activerecord/ActiveRecord.php
Line Number: 41
Backtrace:
File: F:\xampp7\htdocs\project\vendor\php-activerecord\php-activerecord\ActiveRecord.php
Line: 41
Function: implode
File: F:\xampp7\htdocs\project\application\core\MY_Loader.php
Line: 56
Function: spl_autoload_call
File: F:\xampp7\htdocs\project\index.php
Line: 283
Function: require_once

A PHP Error was encountered

Severity: Warning
Message: Use of undefined constant MCRYPT_RIJNDAEL_192 - assumed 'MCRYPT_RIJNDAEL_192' (this will throw an Error in a future version of PHP)
Filename: core/MY_Loader.php
Line Number: 56
Backtrace:
File: F:\xampp7\htdocs\project\application\core\MY_Loader.php
Line: 56
Function: _exception_handler
File: F:\xampp7\htdocs\project\index.php
Line: 283
Function: require_once

A PHP Error was encountered

Severity: Warning
Message: Use of undefined constant MCRYPT_MODE_CFB - assumed 'MCRYPT_MODE_CFB' (this will throw an Error in a future version of PHP)
Filename: core/MY_Loader.php
Line Number: 56
Backtrace:
File: F:\xampp7\htdocs\project\application\core\MY_Loader.php
Line: 56
Function: _exception_handler
File: F:\xampp7\htdocs\project\index.php
Line: 283
Function: require_once

Fatal error: Uncaught Error: Call to undefined function PHPEncryptData\mcrypt_get_key_size() in F:\xampp7\htdocs\project\vendor\archwisp\php-encrypt-data\Simple.php:111 Stack trace: #0 F:\xampp7\htdocs\project\vendor\archwisp\php-encrypt-data\Simple.php(33): PHPEncryptData\Simple->_getKeySize() #1 F:\xampp7\htdocs\project\application\core\MY_Loader.php(58): PHPEncryptData\Simple->__construct('wpOxcuvJLA4Z4aX...', 'YeYcxVpY/ug6zwY...') #2 F:\xampp7\htdocs\project\system\core\Common.php(186): MY_Loader->__construct() #3 F:\xampp7\htdocs\project\system\core\Controller.php(67): load_class('Loader', 'core') #4 F:\xampp7\htdocs\project\system\core\CodeIgniter.php(357): CI_Controller->__construct() #5 F:\xampp7\htdocs\project\index.php(283): require_once('F:\\xampp7\\htdoc...') #6 {main} thrown in F:\xampp7\htdocs\project\vendor\archwisp\php-encrypt-data\Simple.php on line 111

A PHP Error was encountered

Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at F:\xampp7\htdocs\project\system\core\Exceptions.php:211)
Filename: core/Common.php
Line Number: 551
Backtrace:

A PHP Error was encountered

Severity: Error
Message: Uncaught Error: Call to undefined function PHPEncryptData\mcrypt_get_key_size() in F:\xampp7\htdocs\project\vendor\archwisp\php-encrypt-data\Simple.php:111 Stack trace: #0 F:\xampp7\htdocs\project\vendor\archwisp\php-encrypt-data\Simple.php(33): PHPEncryptData\Simple->_getKeySize() #1 F:\xampp7\htdocs\project\application\core\MY_Loader.php(58): PHPEncryptData\Simple->__construct('wpOxcuvJLA4Z4aX...', 'YeYcxVpY/ug6zwY...') #2 F:\xampp7\htdocs\project\system\core\Common.php(186): MY_Loader->__construct() #3 F:\xampp7\htdocs\project\system\core\Controller.php(67): load_class('Loader', 'core') #4 F:\xampp7\htdocs\project\system\core\CodeIgniter.php(357): CI_Controller->__construct() #5 F:\xampp7\htdocs\project\index.php(283): require_once('F:\\xampp7\\htdoc...') #6 {main} thrown
Filename: php-encrypt-data/Simple.php
Line Number: 111
Backtrace:


Share:

0 komentar:

Post a Comment

Blog Archive