Uncaught Error: Call to undefined function CodeIgniter\locale_set_default()
in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184
Stack trace:
#0 C:\xampp\htdocs\sunpay-ci4\system\bootstrap.php(181): CodeIgniter\CodeIgniter->initialize()
#1 C:\xampp\htdocs\sunpay-ci4\public\index.php(36): require('C:\\xampp\\htdocs...')
#2 {main} thrown in C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php on line 184
I don't understand this error, the first page works if I drop this package.
Try opening php.ini from the control panel:
Apache row -> Config -> php.ini
Then enable intl extension by removing ; in front of extension=intl
Edit: the reason it fails is because the intl extension is disabled by default in xampp
Recently I stuck on the same problem on CI version 4.0.4.
Follow the steps to fix it.
Click on "config" from the xampp control panel.
Then click on php.ini option.
Then it will open on your default text editor application (for me it is Notepad). then click on find option.
Then search for ";extension=intl".
replace ";extension=intl" with "extension=intl".
That's all. Thanks.
get your php version by put this code : phpinfo();die(); in your index.php after <?php so it looks like like <?php phpinfo();die();
PHP Version 7.2.24-0ubuntu0.18.04.7
jump to /etc/php/{your php version}/apache2 folder; example : /etc/php/7.2/apache2 and open php.ini then find ;extension=intl and remove the semicolon ;
open your terminal then write or copy paste this command sudo systemctl restart apache2 and press ENTER
open your CI 4 again in your browser.
Welcome to CodeIgniter 4.0.4
The small framework with powerful features
==============================================================================
if you still get the same error please try to install intl extension using this command in your terminal:
sudo apt install php{your php version}-intl
sudo systemctl restart apache2`
example :
sudo apt install php7.2-intl
sudo systemctl restart apache2
open your CI 4 again in your browser.
Welcome to CodeIgniter 4.0.4
The small framework with powerful features
=============================================================================
#NB :
dont forget to remove phpinfo();die(); in the first step
sorry for my bad english
Just go to the mentioned line in display in error.
C:\xampp\htdocs\sunpay-ci4\system\CodeIgniter.php:184
You can find it here: root folder/system/CodeIgniter.php
on line no 184 you will find the below code.
locale_set_default($this->config->defaultLocale ?? 'en');
just comment it like this.
#locale_set_default($this->config->defaultLocale ?? 'en');
Now, the code is working.
1.search for intl and uncomment this extension in php.ini file by removing ; from begin of line extension=intl
2. restart Apache service by stop and starting it again from xampp control panel
When i started a new project i got this error on welcome screen. Fatal error: Uncaught Error: //pp\Views\welcome_message.php:222 Stack trace: #0 {main} thrown in. It appears like there is a problem with the installation of codeigniter but in fact it is an echo error in line 222 of the welcom_message.php page go there an remove the <?= CodeIgniter\CodeIgniter::CI_VERSION ?> from line 222 it should look like this
<div class="heroe">
<h1>Welcome to CodeIgniter </h1>
<h2>The small framework with powerful features</h2>
</div>
Then it will echo hello screen correctly
Usually to get round this try these three points:
Ensure .writable folder is writable with file permissions 0777 (must have leading zero)
Try setting the following in index.php -> $_SERVER['CI_ENVIRONMENT'] = 'development'; and toggle with $_SERVER['CI_ENVIRONMENT'] = 'production' in .env file;
Access this file(CodeIgniter.php) in the following directory: project_folder/vendor/codeigniter4/framework/system/CodeIgniter.php
public function initialize()
{
if( function_exists('locale_set_default' )):
locale_set_default($this->config->defaultLocale ?? 'en');
endif;}
if your have installed Apache, PHP, MYSQL manually, then set locale to app in .env file:
app.locale = "en"
save and restart apache service
Related
Fatal error: Uncaught Error: Call to undefined function ImageCreate() in C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrimage.php:74 Stack trace: #0 C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrimage.php(32): QRimage::image(Array, 5, 4) #1 C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrencode.php(494): QRimage::png(Array, 'temp/184011_inf...', 5, 4, false) #2 C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrencode.php(286): QRencode->encodePNG('\tRoll no: 18401...', 'temp/184011_inf...', false) #3 C:\xampp\htdocs\the_base\qr\index.php(57): QRcode::png('\tRoll no: 18401...', 'temp/184011_inf...', 0, 5) #4 {main} thrown in C:\xampp\htdocs\the_base\qr\libs\phpqrcode\qrimage.php on line 74
This is the error I am getting since I've updated my XAMPP. This same code has worked perfectly with an older version of xampp but when I updated it, the code suddenly started to give this error
I am trying to create a QR code in png format and make it downloadable
I did a little research about it, it said that the GD lib was missing in the PHP but all the steps shown to fix it were of LINUX OS, I am currently using Windows.
go to php.ini file xampp/php/php.ini
search for ;extension=gd and ;extension=gd2
remove the ; from both lines, then restart the server
there might be two cases:
1.gd installed and disabled
2. gd not installed and disabled
for first case:
on XAMPP server click on Apache config -> php.ini
1.open this file in notepad
2. search for ;extension=gd or ;extension=gd2
3. remove the colon ; ( just extension=gd)
4. save it .
for second case gd not installed:
check it through:
(on browser) localhost/dashboard
xampp dashboard opens up, on upper left go to phpinfo()
search for gd section if not present then follow down:
1.open folder : xampp/php/ext
2. then find and Copy php_gd.dll and paste it into the following folder
3.C:\Windows\System32
4. paste php_gd.dll here.
5. restart xampp server and run.
for better explanation:
https://www.geeksforgeeks.org/how-to-install-php-gd-in-windows/
It seems like the php_gd2 extension isn't enabled.
you have to enable it in php.ini. To do this, simply open php.ini and uncomment (remove the leading ;) the following line:
extension=php_gd2.dll
When i try using the GD Library in PHP 7.4.6 on my Windows PC, it shows me this error:
Fatal error: Uncaught Error: Call to undefined function imagecreate() in C:\Users\user\Desktop\Site\index.php:11 Stack trace: #0 {main} thrown in C:\Users\user\Desktop\Site\index.php on line 11
The line 11 is:
$image = imagecreate(200,20);
The full PHP code is:
<?php
$image = imagecreate(200,20);
$background = imagecolorallocate($image,0,0,0);
$foreground = imagecolorallocate($image, 255,255,255);
$imagestring($image,5,5,1,"Test",$foreground);
$header("Content-type: image/jpeg");
$imagejpeg($image);
?>
I tried fixing this by following this guide, and i uncommented the GD line, but it still gives me this error.
Thanks in advance.
Do a php -m to see PHP modules. If you can't find gd there then you need to install and enable that extension. There a lot of tutorials in internet to doing so
I had the same problem with apache and GD.
See https://stackoverflow.com/a/72565820/9630486
The problem was in php.ini path for apache. By default it is not using php.ini from php directory. You need to define PHPIniDir in httpd file or place copy of php.ini to apache folder.
Go to php.ini file search this
;extension=gd
Remove ; then restart the server
Try this code:
<?php
phpinfo();
Search for "GD Support" in the resulting output. If you don't see it or it's not enabled, you need to enable gd in php.ini - search for:
;extension=php_gd2.dll
Remove the comment in front of it, save the ini file, and restart IIS/Apache/Nginx/whatever server you're running.
I get this error on my production server (CentOS 5.4 and php 5.3.5) :
Warning: include_once(PharData.php): failed to open stream: No such
file or directory in /var/www/ZendFramework/library/Zend/Loader.php on
line 146
Warning: include_once(): Failed opening 'PharData.php' for inclusion
(include_path='/var/www/fw:/var/www/vmms:/var/www/ZendFw/library:.:/usr/share/pear:/usr/share/php')
in /var/www/ZendFw/library/Zend/Loader.php on line 146
Fatal error: Class 'PharData' not found in
/var/www/vm/app/Backup.php on line 40
And this is the code which fail :
$phar = new PharData($imageBackupFile);
$phar->buildFromDirectory($imageDir);
Logger::info("Image directory backed up to: $imageBackupFile");
This code is working fine on my own computer.
PharData should be included by default in php 5.3+ ...
Thanks for your help!
UPDATE :
I am using the Zend Auto loader feature to load the good php files using this code :
require_once("Zend/Loader/Autoloader.php");
$autoloader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
Zend autoloader is doing the include_once(PharData.php).
Just because Phar is bundled by default in PHP 5.3 doesn't mean that it's necessarily included in your install. When you build PHP with ./configure, you can pass the --disable-phar to disable the Phar extension.
To confirm this, run the following script:
<?php
phpinfo();
?>
One of the first sections to appear will be the Configure Command section. Review this section to see if the --disable-phar switch is present, and if there is a Phar section to the page in general.
If it's not present, you'll need to contact your host to have it enabled. There's a decent chance, however, that they won't do it for you since it could impact other users depending on how their servers are set up. If this is on your own machine, you'll need to either rebuild PHP without that switch, or install Phar manually from PECL (no idea if this would still work in 5.3, but I don't see why it wouldn't).
Apparently my last question was too vague even though it was pretty straightforward.
I'm trying to use Embed.ly's API to embed some stuff, for example, some of the stuff shown here.
https://github.com/embedly/embedly-php/blob/master/README.rst
I have the entire Embedly.php source file in my working directory.
However, when I have the following in my header file:
<?php
//require_once('Embedly/src/Embedly/Embedly.php'); // if using pear
require_once('./Embedly.php'); // if using source
$api = new Embedly\Embedly(array('user_agent' => 'Mozilla/5.0 (compatible; mytestapp/1.0)'));
?>
And the following in my main page:
<?php
$objs = $api->oembed(array(
'urls' => array(
'http://www.youtube.com/watch?v=sPbJ4Z5D-n4&feature=topvideos',
'http://twitpic.com/3yr7hk'
)
));
?>
I get the following error:
( ! ) Fatal error: Call to undefined function Embedly\curl_init() in C:\wamp\www\Embedly.php on line 259
It looks like curl isn't installed or enabled.
If you're on you own server (assuming something similar to ubuntu server), a simple sudo apt-get install php5-curl should solve it.
Otherwise, you may have to contact your hosting provider.
Got this from a forum and it seems legit:
Close WAMP (if running)
Navigate to WAMP\bin\php(your version of php)\
Edit php.ini
Search for curl, uncomment extension=php_curl.dll
Navigate to WAMP\bin\Apache(your version of apache)\bin\
Edit php.ini
Search for curl, uncomment the line/remove the #, extension=php_curl.dll
Save the files
Restart WAMP
Racking my head as to why I can't include the Zend-framework into my project. The documentation is unclear about how to set up the environment (Or haven't found where it is). Looked at this thread: How to configure Zend Framework on linux machine? but no luck. In the phpinfo() I see Zend configured but why can't I use it? Looked for documentation on how to add this to PEAR/PECL, no luck.
I did see this post: http://devzone.zend.com/article/4683 but still not working
What I have tried:
Option 1
require_once('/usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php');
Zend_Loader_Autoloader::getInstance();
Option 2
sudo vi /etc/php5/apache2/php.ini
changed this line:
;include_path = ".:/usr/share/php"
to:
include_path=".:/usr/share/php:/usr/share/pear:/usr/share/php/libzend-framework-php"
restarted Apache
Getting this error:
Warning: require_once(Zend/Loader.php): failed to open stream: No such file or directory in /usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php on
line 24
Call Stack:
0.0002 61600 1. {main}() /var/www/webservice/zend/server.zend.xmlrpc.php:0
0.0009 174412 2. require_once('/usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php') /var/www/webservice/zend/server.zend.xmlrpc.php:2
Fatal error: require_once(): Failed opening required 'Zend/Loader.php' (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/libzend-framework-p
hp/Zend/Loader/Autoloader.php on line 24
Call Stack:
0.0002 61600 1. {main}() /var/www/webservice/zend/server.zend.xmlrpc.php:0
0.0009 174412 2. require_once('/usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php') /var/www/webservice/zend/server.zend.xmlrpc.php:2
i would suggest to
chmod 775 /usr/share/php/libzend-framework-php -R as Ran BarZik suggestion .
and double check the apache user's permissions .
then symlink it to the your application library by using this :
ln -s /var/www/webservice/library/Zend /usr/share/php/libzend-framework-php/
I;ve installed Zend FW on many Linux system and if I encountered problems it was on the include path that was set incorrectly or permission problem.
Maybe the path isn't right, try 'vi /usr/share/php/libzend-framework-php/Zend/Loader/Autoloader.php' or any other text editor that you like. Does it work?
Maybe it is permission problem, try to change /usr/share/php/libzend-framework-php/ to 755:
chmod 775 /usr/share/php/libzend-framework-php -R
Your main configuration should be in: application/configs/application.ini
This tells the zend controller where to look for the library files etc.
Did you look here when you were installing? : http://framework.zend.com/manual/en/learning.quickstart.create-project.html
According to the error messages, your updated include_path isn't being picked up.
What does phpinfo() have to say about your include_path?
What if you set_include_path(get_include_path . ':/usr/share/php/libzend-framework-php'); before your include?
I'm assuming here that /usr/share/php/libzend-framework-php/Zend exists...
Try to move zend library:
cd /usr/share/php/libzend-framework-php
mv library/Zend /usr/share/php/
revert include_path to original:
include_path = ".:/usr/share/php"
Restart apache
After banging my head up against the wall for a couple of days I think I figured it out. Looking at this page: http://devzone.zend.com/article/4683 I understood I needed to add the zend path in the php.ini file. I did this with no effect. After looking at my PHP Configuration I noticed in /etc/php5/conf.d/ I could load zend by uncommenting the library path in the zend-framework.ini file which PHP loads as an additional module/ini