Does Visual Studio Code suggest entities to you?
↧
Visual Studio Code suggest entities
↧
Graphic Friendly URL
Hello everyone, I do not have much experiences PHP code , There are 3 month i learn PHP language and my friend tell to me CodeIgniter . How to make custom php graphic blog URL? if know anyone please tell me.
Thanks
Thanks
↧
↧
Token csrf codeigniter 4/3 regeneration
Hi, do you know the best methods to regenerate the csrf token on ajax form submission?
↧
Config mail using settings
HI,
is there a way to use https://github.com/codeigniter4/settings to config email instead of Config/Email
i try to use :
But if i try to send email i have no smtp configured
is there a way to use https://github.com/codeigniter4/settings to config email instead of Config/Email
i try to use :
Code:
service('settings')->set('Email.protocol', 'smtp');
service('settings')->set('Email.SMTPHost', 'smtps.xxxxx.it');
service('settings')->set('Email.SMTPUser', 'noreply@xxxxxx.it');
service('settings')->set('Email.SMTPPass', 'xxxxxx');
service('settings')->set('Email.SMTPPort', '465');
service('settings')->set('Email.SMTPCrypto', 'ssl');
↧
[VALIDATION] - Upload excel fail
I have validation file upload excel
And here var_dump($_FILES);
How solve this?
PHP Code:
if ($this->request->getFile('fileBuktiSelisihTxt')) {
$folderLocationKonfirmasi = $this->getFolderKonfirmasiData($idKreditur);
if ($this->validate([
'fileBuktiSelisihTxt' => [
'label' => 'Data Selisih Polis Batal',
'rules' => [
'uploaded[fileBuktiSelisihTxt]',
'ext_in[fileBuktiSelisihTxt,xlsx,xls]',
'mime_in[fileBuktiSelisihTxt,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/msexcel,application/x-msexcel,application/x-ms-excel,application/x-excel,application/x-dos_ms_excel,application/xls,application/x-xls,application/excel,application/download,application/vnd.ms-office,application/msword]',
'max_size[fileBuktiSelisihTxt,1048]',
],
],
])) {
$errors = $this->validation->getErrors();
$arrReturnInvalid = [
'r_status' => false,
'r_data' => [
'status' => 'warning',
'message' => $errors,
],
'r_code' => 400,
'r_message' => 'Bad Request',
];
return json_encode($arrReturnInvalid, JSON_PRETTY_PRINT);
}
$params_file = $this->request->getFile('fileBuktiSelisihTxt');
if ($params_file->isValid() && ! $params_file->hasMoved()) {
$extFile = $params_file->getExtension();
$timeNow = Time::now();
$makeFile = $params_file->getBasename('.' . $extFile) . '_' . $timeNow->getTimestamp() . '_CHECK.' . $extFile;
\log_message('info', 'MASUK SNI APPROVAL');
if ($params_file->move($folderLocationKonfirmasi, $makeFile, true)) {
\log_message('info', 'MASUK SANA APPROVAL');
$postData['fileBuktiSelisih'] = $makeFile;
}
}
}
And here var_dump($_FILES);
Code:
array(2) {
["fileBuktiPolisTxt"]=>
array(6) {
["name"]=>
string(37) "ajukan-xxxx-2024-10-15-11-4-20.xlsx"
["full_path"]=>
string(37) "ajukan-xxxx-2024-10-15-11-4-20.xlsx"
["type"]=>
string(65) "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
["tmp_name"]=>
string(46) "C:\Users\ABC-PC\AppData\Local\Temp\php174A.tmp"
["error"]=>
int(0)
["size"]=>
int(17920)
}
["fileBuktiCancelPolisTxt"]=>
array(6) {
["name"]=>
string(18) "xxxxx.xlsx"
["full_path"]=>
string(18) "xxxxx.xlsx"
["type"]=>
string(65) "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
["tmp_name"]=>
string(46) "C:\Users\ABC-PC\AppData\Local\Temp\php174B.tmp"
["error"]=>
int(0)
["size"]=>
int(9047)
}
}
How solve this?
↧
↧
error on forum website
the site is fierce slow today. is it because of this chrome message?
"Refused to execute script from 'https://forum.codeigniter.com/jscripts/theme-effects.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."
Bill
"Refused to execute script from 'https://forum.codeigniter.com/jscripts/theme-effects.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled."
Bill
↧
Using Dynamic Database Names
I am trying to create a dynamic database connection from a model and can't seem to do it.
We have a separate database for each customer, so the database name would be like db_1001, db, 1002, db_1003, etc (production names are more secure).
The 1001, 1002, 1003 is stored in a session variable when they login. So what I need is below:
But I get the error:
ErrorException: Constant expression contains invalid operations in APPPATH/Config/Database.php on line 93
I assume because the Database class is static?
So how would I accomplish this?
Can I put the database credentials in the Model?
It's instantiated in the model like this now:
We have a separate database for each customer, so the database name would be like db_1001, db, 1002, db_1003, etc (production names are more secure).
The 1001, 1002, 1003 is stored in a session variable when they login. So what I need is below:
PHP Code:
public array $customer = [
'hostname' => 'localhost',
'username' => 'fa_customer',
'password' => 'abcd1234',
'database' => 'db_' . $this->session->customer_id',
...
...
];
But I get the error:
ErrorException: Constant expression contains invalid operations in APPPATH/Config/Database.php on line 93
I assume because the Database class is static?
So how would I accomplish this?
Can I put the database credentials in the Model?
It's instantiated in the model like this now:
PHP Code:
$customer_db = \Config\Database::connect('customer');
↧
Input validation return empty array
I'm facing a weird issue trying to validate post input.
Following the userguide I set a controller to validate few POST input sent using a form.
The controller is the following:
In my view, using a print_r command, I get and empty array as 'validated' data...while 'errors' return the error if input are not valid. I really cannot understand what's wrong with $validData and why I get an empty array. Anny hint or help to figure out what's wrong?
Thanks a lot for any help.
Following the userguide I set a controller to validate few POST input sent using a form.
The controller is the following:
Code:
public function collection()
{
if ( $this->request->is('post')) {
$rules = [
'record' => 'alpha_numeric_punct',
'record_id' => 'is_natural_no_zero',
'region' => 'is_natural_no_zero',
];
$data = $this->request->getPost(array_keys($rules));
if (! $this->validateData($data, $rules)) {
$errors = $this->validator->getErrors();
}
$validData = $this->validator->getValidated();
$data['validated'] = $validData;
$data['errors'] = $errors;
}
}
In my view, using a print_r command, I get and empty array as 'validated' data...while 'errors' return the error if input are not valid. I really cannot understand what's wrong with $validData and why I get an empty array. Anny hint or help to figure out what's wrong?
Thanks a lot for any help.
↧
Interaction between Wordpress and 2 seperate CI4 applications
I have a project on the go where I have to get Wordpress to interact to 2 CI4 applications. The basic process is:
User log in to Wordpress -> If the user has a valid subscription Wordpress then triggers a process that will create a session in both of the CI4 applications. User then clicks on link on their landing page to access either of the CI4 applications.
One of the CI4 applications we developed ourselves, the 2nd is a 3rd party application.
If anybody has done anything like this please let me know what tools and/or method you used to achieve the desired result.
User log in to Wordpress -> If the user has a valid subscription Wordpress then triggers a process that will create a session in both of the CI4 applications. User then clicks on link on their landing page to access either of the CI4 applications.
One of the CI4 applications we developed ourselves, the 2nd is a 3rd party application.
If anybody has done anything like this please let me know what tools and/or method you used to achieve the desired result.
↧
↧
Email Activation Issue at CodeIgniter Shield
Hello everyone!
I have issue at registering new user via AJAX requests, so other things are ok except this one:
For example, a visitor tries register with an email that its not owned by: example @ example.com, so the visitor could not active the registration.
But if another visitor tries register with that email address (so example @ example.com), what happens? I tell you, it says the email address already used.
How can i solve this issue?
Best.
I have issue at registering new user via AJAX requests, so other things are ok except this one:
For example, a visitor tries register with an email that its not owned by: example @ example.com, so the visitor could not active the registration.
But if another visitor tries register with that email address (so example @ example.com), what happens? I tell you, it says the email address already used.
How can i solve this issue?
Best.
↧
1500+ Free HTML Website Templates on HTMLrev
(DEV.TO article/link) 1500+ Free HTML Website Templates on HTMLrev - DEV Community
↧
Machine Learning in PHP: Build a News Classifier Using Rubix ML
(DEV.TO - PHP and AI) Machine Learning in PHP: Build a News Classifier Using Rubix ML - DEV Community
↧
magic link login
Good morning,
I have a problem with the magic link.
probably in following the guide, I made some mistakes or I didn't understand some steps well.
basically when I request the login link, I get the email, the code it sends is correct, I also checked it in the database.
but when I try to enter with that link, it tells me it has expired.
In the configuration I put:
public bool $allowMagicLinkLogins = true;
public int $magicLinkLifetime = 3600;
so technically it should be valid for an hour.
reading the guide it doesn't seem to me that there are other files or other configurations, in addition to the email, to set.
obviously excluding the page for changing the password.
how can I check the flow and identify the problem?
thanks!
I have a problem with the magic link.
probably in following the guide, I made some mistakes or I didn't understand some steps well.
basically when I request the login link, I get the email, the code it sends is correct, I also checked it in the database.
but when I try to enter with that link, it tells me it has expired.
In the configuration I put:
public bool $allowMagicLinkLogins = true;
public int $magicLinkLifetime = 3600;
so technically it should be valid for an hour.
reading the guide it doesn't seem to me that there are other files or other configurations, in addition to the email, to set.
obviously excluding the page for changing the password.
how can I check the flow and identify the problem?
thanks!
↧
↧
Proper base url
Hello Everyone,
I'm experiencing an issue with the base URL. I've tried changing the base URL in the .env file as follows:
However, I keep getting the following error:
The requested resource /amp/ was not found on this server.
When I try accessing another link, such as
I get a controller error:
I attempted to use a route group for amp and it works for /amp/(.*) , but not for /amp itself.
Here’s the route configuration I used:
$routes->group('amp', function($routes) {
$routes->get('/', 'Dashboard::index');
$routes->add('authsso/(
egment)', 'Dashboard::authsso/$1');
$routes->post('dashboard/grafik', 'Dashboard::grafik');
});
Does anyone have a solution for this issue?
I'm experiencing an issue with the base URL. I've tried changing the base URL in the .env file as follows:
Code:
app.baseURL = 'http://localhost/amp'
The requested resource /amp/ was not found on this server.
When I try accessing another link, such as
Code:
/amp/frontend
Code:
Controller or its method is not found: \App\Controllers\Amp::frontend
Here’s the route configuration I used:
$routes->group('amp', function($routes) {
$routes->get('/', 'Dashboard::index');
$routes->add('authsso/(

$routes->post('dashboard/grafik', 'Dashboard::grafik');
});
Does anyone have a solution for this issue?
↧
Slowing down the Internet
Hi. We all know the situation in the world. Recently, a provider in the country blocked ECH (uses Cloudflare) and many resources stopped opening. Including the forum.
I just want to say that I will come less (vpn seems to work).
Thanks
I just want to say that I will come less (vpn seems to work).
Thanks
↧
Should the variable type for language keywords be static or const?
Hello everyone,
I'm designing a multilingual project, and I created a folder named Constants with a file called LanguageKeys.php inside it. The structure looks like this:
Do you think these should stay as they are, or would it be better to make them
public static instead? These keys are saved to Redis from the database, and unless revalidation is done, the data is queried from Redis.
Do you have any suggestions or thoughts on this?
I'm designing a multilingual project, and I created a folder named Constants with a file called LanguageKeys.php inside it. The structure looks like this:
PHP Code:
namespace App\Constants;
class LanguageKeys {
public const ALLOWED_LOCALS = ["tr", "en", "de"];
public const SUCCESS = 'RESPONSE_SUCCESSFULLY_MESSAGE';
public const FAIL = 'RESPONSE_UNSUCCESSFULLY_MESSAGE';
public const CREATE_SUCCESS = 'RESPONSE_CREATE_SUCCESSFULLY_MESSAGE';
}
public static instead? These keys are saved to Redis from the database, and unless revalidation is done, the data is queried from Redis.
Do you have any suggestions or thoughts on this?
↧
include javascript in CI4 view
Hi guys, I am struggling with add a javascript file into my view in CI4
in CI3 I just did $this->load->view('js/dtArtigos.js'); to load a datatable definition with some php in the mix like <?php
$settings = new \Config\Conffile();
?> .
I have tried inside script tag
<? = $this->include('js/dtArtigos.js');?> with no luck
<?=file_get_contents( __DIR__ . '/js/dtArtigos.js'); ?> with no luck
for organization purposes I like the javascript files inside views, folder view controller like for example products and a a folder js to hold my js
for example
--/app/Views/products/js
What is the correct way to have this working? I prefer nor ro do <script src="xxxxxx"></script> but echoing the file contect in view file inside script tag
Many thanks!
in CI3 I just did $this->load->view('js/dtArtigos.js'); to load a datatable definition with some php in the mix like <?php
$settings = new \Config\Conffile();
?> .
I have tried inside script tag
<? = $this->include('js/dtArtigos.js');?> with no luck
<?=file_get_contents( __DIR__ . '/js/dtArtigos.js'); ?> with no luck
for organization purposes I like the javascript files inside views, folder view controller like for example products and a a folder js to hold my js
for example
--/app/Views/products/js
What is the correct way to have this working? I prefer nor ro do <script src="xxxxxx"></script> but echoing the file contect in view file inside script tag
Many thanks!
↧
↧
CodeIgniter helper functions
In CodeIgniter helper functions, I've seen that they check if they're being declared already before declaring like this:
Why is this necessary? I feel it's less readable and not good for code maintenance in the long run. Is there any workaround to this? For example, can I ensure in some other way that my helper.php will be loaded only once and not multiple times?
Code:
if(!function_exists('foo'))
{
function foo()
{....
}
}
Why is this necessary? I feel it's less readable and not good for code maintenance in the long run. Is there any workaround to this? For example, can I ensure in some other way that my helper.php will be loaded only once and not multiple times?
↧
Creating SMS OTP Using Shield
Hi,
I'm trying to build a function to send SMS for two-factor authentication (2FA) instead of using email for 2FA. However, I got stuck trying to override the existing authentication handler function, which creates a 6-digit code and sends it to the user's email address. I want to create a new function to replace that. I'm using CI4 + Shield
I'm trying to build a function to send SMS for two-factor authentication (2FA) instead of using email for 2FA. However, I got stuck trying to override the existing authentication handler function, which creates a 6-digit code and sends it to the user's email address. I want to create a new function to replace that. I'm using CI4 + Shield
↧
Error 500 on my vps server, but when i refresh its just running normally
i dont know why i get error like this, so when my server is on production my server usually get an error, but when i refresh its just going well, but i get this error in many times, i've tried everything but its still like that, whats the problem, and when i try to check it the error is like this
A PHP Error was encountered
Severity: WarningA PHP Error was encountered
Message: Attempt to read property "db" on null
Filename: Session/Session.php
Line Number: 812
Backtrace:
File: /var/www/html/zonaapoteker/application/controllers/Home.php
Line: 18
Function: set_userdata
File: /var/www/html/zonaapoteker/index.php
Line: 307
Function: require_once
An uncaught Exception was encountered
Type: Error
Message: Call to a member function empty_table() on null
Filename: /var/www/html/zonaapoteker/system/libraries/Session/Session.php
Line Number: 812
Backtrace:
File: /var/www/html/zonaapoteker/application/controllers/Home.php
Line: 18
Function: set_userdata
File: /var/www/html/zonaapoteker/index.php
Line: 307
Function: require_once
↧