How to install php utilities that are not included in xampp

Problems with the Windows version of XAMPP, questions, comments, and anything related.

How to install php utilities that are not included in xampp

Postby vvucic » 08. August 2018 11:54

Hello,

How to install PHP utilities/modulesthat are not included in default install of XAMPP. For example, I need iconv and forceutf8, but I am not sure how to make them available.

Thanks
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 08. August 2018 12:14

Iconv should be enabled in Xampp (i checked my Linux Installation and it is part of PHP, it should be also enabled in Windows). Run a phpinfo (there is a link in the dashboard) and search for iconv, it should be there.

forceutf8 is not a module neither an extension, its simply a PHP script which has to be included in your PHP scripts. You can download a ZIP Package from GitHub and extract it to your htdocs folder, there is a README.md included.

FInally,if you really need a binary module which is not part of Xampp, there is no way to adapt it. You only can compile new modules by yourself, but this requires a working development environment as well as sophisticated skills, its easier done on Linux than on Windows.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: How to install php utilities that are not included in xa

Postby vvucic » 08. August 2018 14:42

When I Got command prompt and I execute command:
iconv -f ISO8859-1 -t utf8 myold file mynewfile
I get message
iconv is not recognized as internal or external command operable program or batch file.
I installed idtas binary in my win with intl.dll that was missing and I succeeded to start it.
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 08. August 2018 15:02

Of course, you confuse the command tool iconv with the PHP library iconv. The command tool is not part of Xampp, but is part of the operating system for Linux.
If there is also a command tool iconv for Windows, you have to search with Google. But this has nothing to do with Xampp at all.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: How to install php utilities that are not included in xa

Postby vvucic » 08. August 2018 16:14

OK. But, how can I use PHP Library iconv?
I installed it in win and Linux machines.
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 08. August 2018 19:48

vvucic wrote:OK. But, how can I use PHP Library iconv?
I installed it in win and Linux machines.


Read the documentation: http://php.net/manual/en/book.iconv.php
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: How to install php utilities that are not included in xa

Postby vvucic » 08. August 2018 19:50

Thanks.. Hmm, but can string be whole .sql database?
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 09. August 2018 11:11

You cannot convert a whole database with a simple iconv, neither with PHP library nor with commandline tool. If your database contains binary data, it will be corrupted.

There are plenty of postings in the WWW about converting database from latin1 to utf8, simply enter "how to convert mysql database from latin1 to utf8" into Google. I found some very handy scripts which basically are using mysqldump (which knows the table structures of your database, what iconv does not know) to export the database into the desired format.

P.S.: I just found this sneaky solution, i did not test it, but it looks very simple. Open phpmyadmin or run mysql and enter this SQL Statement:

Code: Select all
ALTER DATABASE databasename CHARACTER SET utf8 COLLATE utf8_unicode_ci;


I dont know if this really converts all characters to utf8 (or if it only changes the datatype, without changing the data) but its definately worth a try! DONT FORGET TO BACKUP YOUR DATA BEFORE RUNNING ANYTHING!!!

P.P.S.: Just found out, that the above ALTER does NOT convert any characters. You have to convert the tables by using ALTER TABLE ... CONVERT:

Code: Select all
ALTER TABLE tbl_name CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;


Here is a very usefull posting, which shows everything you need: https://stackoverflow.com/questions/611 ... n-to-utf-8

There is also a shell script shown, which automatically loops over all the tables of a database and runs the CONVERT of the character:

Code: Select all
DB="dbname"
(
    echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'
    mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names \
    | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;'
) \
| mysql "$DB"


Or, in one line:

Code: Select all
DB="dbname"; ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'; mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) | mysql "$DB"
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: How to install php utilities that are not included in xa

Postby vvucic » 09. August 2018 16:34

How to get into console/terminal in XAMPP for Windows in order to execute that command?
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 09. August 2018 17:13

Not in Xampp, terminal is part of Operating System. The script examples above are Linux based, therefore you have to start a terminal in Linux.

On the site i linked here, there is also a plain SQL solution shown, without terminal and/or shell scripts. You may use that for your needs, if you are lacking knowledge about terminals.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: How to install php utilities that are not included in xa

Postby vvucic » 09. August 2018 17:37

So, I Guess, I have to install mysql in Linux machine, start SQL and in terminal prompt issue that command assuming that database is in the same folder so the comand can find it and be executed properly.
I tried SQL command but it did not work. The real solution should be something like this
https://github.com/neitanod/forceutf8
When you see in usage part of that page the idea is that it should output correct coding instead of garbled. So, change of collation and characterset is not necessarily sufficient.
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 09. August 2018 19:34

vvucic wrote:So, I Guess, I have to install mysql in Linux machine, start SQL and in terminal prompt issue that command assuming that database is in the same folder so the comand can find it and be executed properly.


No. That is ridiculous. Obviously you are mixing up commandline tools and the mysql interpreter, which of course does not work.

vvucic wrote:I tried SQL command but it did not work.


What did not work, what are the error messages and what did you try to fix it?
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04

Re: How to install php utilities that are not included in xa

Postby vvucic » 09. August 2018 22:17

When I start it in terminal as root user I have got the following error message:
DB="ojs-upgrade-endcoding.sql"; ( echo 'ALTER DATABASE `'"$DB"'` CHARACTER SET utf8 COLLATE utf8_general_ci;'; mysql "$DB" -e "SHOW TABLES" --batch --skip-column-names | xargs -I{} echo 'ALTER TABLE `'{}'` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;' ) | mysql "$DB"
When I started mysql I have got the following error message
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DB="ojs-upgrade-endcoding.sql"' at line 1

I want to make solution like forceutf to double encoded strings that produce garbled characters .
vvucic
 
Posts: 20
Joined: 19. March 2009 00:06

Re: How to install php utilities that are not included in xa

Postby Nobbie » 10. August 2018 10:10

vvucic wrote:When I start it in terminal as root user I have got the following error message:.


I cannot see any error message there?! Anyway, i think you have to apply a username and a password to the mysql call (mysql "$DB") in that command, this is only an example you have to adapt it to your needs.

You MUST NOT start mysql in a terminal, simply paste that script into a shell prompt. I also recommend the first version of the script (multiple lines). If you dont get it working, proceed to the URL i gave to you and look for the other solution running in mysql.

vvucic wrote:I want to make solution like forceutf to double encoded strings that produce garbled characters .


So your data is already corrupted? In that case you cannot use the above solution, it requires clean data. If your characters are already corrupted, i cannot help any further.
Nobbie
 
Posts: 13170
Joined: 09. March 2008 13:04


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 123 guests