Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Aug 13, 2019

Troubleshooting Cakephp 3 showing "Blank page" (Clue: internationalisation (i18n))

Understanding i18n

To implement multiple languages in your webpage, you need internationalisation (or i18n, start with an alphabet "i", 18 alphabet in the middle and end with an "n").

If you have came across this feature, you'll know you need your static content written in the following format:

echo __('Text to be translated');


And the "Text to be translated" will appear in your Locale folder's in "po" formatted file.

Potential cause of the "Blank page"

Overview of the findings, the "blank" page appears in:

  • complete blank screen and show nothing, 
  • browser is showing correct code in the HTML page source (without HTML code from chosen layout)
  • page goes blank without any warning/error messages

Things to check for the issue

  • is the "__()" written correctly? Make sure it's 2 underscores + text in the bracket.
  • Search your source code and find if there is any mistakenly written single underscore "_()" i18n syntax
  • be warned, you won't get any error message from single underscore i18n syntax "_()" mistake


References:
CakePHP 3 - Internationalization & Localization
CakePHP 3 - Global function __()

Oct 27, 2016

Apache not loading PHP after SierraOS upgrade (Homebrew way)

Had a hard time dealing with Apache Server + PHP on my Mac right after SierraOS upgrade.

I use homebrew to get my Mac run with latest PHP7 version instead of directly messing around with the original library come with the SierraOS.

Firstly, the latest update of homebrew, PHP module has no longer installed with Apache.
You need:
brew install php70 --with-apache
in order to download the PHP with libphp7.so 
(this is the file you need when you use apache to load php module)

2nd, after you have Apache downloaded with your PHP through homebrew.
All the manual configurations, by default,
have to be done inside /usr/local/etc/apache2/2.4 (yours might be 2.2, based on your installed version).
Remember those httpd.conf, httpd-vhost.conf, etc... they're all inside the /usr/local/etc/apache2/2.4 folder?

and add a missing media type to your mime_module which it's the most obscure step (to a beginner like me) to missed out during configuration.
AddType application/x-httpd-php .php
Symptom check (whether or not to add the line above):
- php module is loaded correctly, but plain php code still showing in your localhost, for instance, php_info() doesn't work

- your sudo apachectl configtest show nothing wrong "Syntax OK"

Aug 4, 2015

Enable PHP extension

Since I use homebrew to install PHP (Command: brew install php56)

And so, we'll have my php.ini file located in other directory.
which is,
/usr/local/etc/php/5.6/php.ini

so you'll have to edit this file in order to activate extension.
In the file, in the Dynamic Extensions part, you will see a list of commented out extensions.


;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_fileinfo.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mbstring.dll


Install desired extension eg.

brew install php56-mcrypt

remove the semicolon ";" at the desired extension to enable it.
and then restart apache server with


sudo apachectl restart 

your extension would be ready for action.

Sep 10, 2013

Bootstrap: Automatically add asterisk symbol to detected 'required' form input field

$('input').each(function(){
   if($(this).is('[required=required]')){
    if ($(this).is('[noAsterisk]')){
    return null;
   } else {
       $(this).closest(".YourClassName").children("label").append('<font style="color:red;position:absolute;" > *</font>');
   }
   }
});

* javascript above require jQuery
with the code:
if ($(this).is('[noAsterisk]')){
     return null;
}
allow you to add exception with 'noAsterisk', where you don't require asterisk as there had 'required' html tag appended.