PHP GTK module in php.ini

2020-02-15 06:52发布

I installed PHP GTK in C:\php-gtk but when I go to run it like from the command line like this

cd C:\php-gtk2
php demos\phpgtk2-demo.php

It gives this error

Please load the php-gtk2 module in your php.ini

My ini file has this content (it is called php-cli.ini)

[PHP]

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; About the php.ini in PHP-GTK ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; This file introduces the php.ini settings that you will need in order to
; run PHP-GTK on your system. You may also need other settings from PHP's
; standard php.ini file, e.g. to load further extensions or otherwise control
; PHP's behaviour in matters such as error reporting. Please add those in
; the upper part of this file, in the PHP section.

; You should use PHP's CLI executable to run PHP-GTK. This php.ini file
; should be in the same directory as the PHP executable, to avoid conflict
; with any other copies of PHP that may be installed on your machine.

; The first thing you will need to do is tell PHP where you want it to look
; for the PHP extension libraries (php_*.dll or php_*.so files) on your system.

extension_dir = "./ext"

; Make sure that php-gtk2.dll under Windows, or php-gtk2.so under Unix, is in
; the directory named in extension_dir alongside any other shared PHP extensions
; you intend to use, and tell PHP to load it.

extension = php_gtk2.dll
;extension = php_pdo.**
;extension = php_sqlite.**
;extension = php_pdo_sqlite.**

[Date]
; Defines the default timezone used by the date functions
;date.timezone = 

[PHP-GTK]

;;;;;;;;;;;;;;;;;;;;;;
; PHP-GTK extensions ;
;;;;;;;;;;;;;;;;;;;;;;

; Extensions written for PHP-GTK are in the format php_gtk_*.dll (Windows) or
; php_gtk_*.so (Unix), written here as a comma-separated list. The library
; files need to be in the same directory as the PHP-GTK library, along with
; any other PHP extensions you are using.

;php-gtk.extensions = php_gtk_libglade2.dll,php_gtk_sourceview2.dll

;;;;;;;;;;;;;
; Code Page ;
;;;;;;;;;;;;;

; The string variables used for titles and other text values in GTK+ are
; encoded in UTF-8 internally. A code page is needed so that PHP-GTK 'knows'
; which character set is being used, and can convert it to UTF-8 as necessary.

; If your environment uses UTF-8 already, you can set the codepage directive
; to UTF-8 to skip the conversions.

; The default codepage setting in PHP-GTK 2 is ISO-8859-1, but you can also
; use either OEM (e.g. 850) or Windows Code Pages (e.g. CP1250) here, so
; long as the encoding format you choose is capable of iconv conversion. See
; http://www.microsoft.com/globaldev/reference/cphome.mspx for a list of
; the code pages and character sets that are supported on Windows systems.

php-gtk.codepage = CP1250

What do I need to do? Is there something wrong with the ini file? Do I need to rename it? What is the problem that is tripping up the program?

3条回答
冷血范
2楼-- · 2020-02-15 07:14

Just solved the problem.

I was trying to run the demo script from the demos folder. But when I tried it with the same folder where the php.exe is it ran smoothly. So there is no problem with the php-cli.ini or no need to worry about this error "Please load the php-gtk2 module in your php-cli.ini"

So Goodluck with PHP-GTK.

查看更多
Anthone
3楼-- · 2020-02-15 07:16

you can take it a bit further, and not worry about paths, I work in Windows environment and I use relative paths even inside .ini like this:

extension_dir = "ext"
extension = php_cairo.dll
extension = php_mongo.dll

This allows me to move the php-gtk folder anywhere.

As for running my projects I do a similar thing, I create .cmd files like this:

"%CD%\..\..\PhpGtkRuntime\php.exe"  "%CD%\index.php"

So you can have for example a central folder and in a subfolder goes php-gtk and in an other one all you projects like this:

php-gtk/PhpGtkRuntime 
php-gtk/Projects

The whole idea is that I distribute a folder to the final user with a run.cmd inside it and the user does a simple copy paste of the folder, really nothing else. I have made an example package with MongoDB included and all of it is portable even MongoDB, Check here..

查看更多
趁早两清
4楼-- · 2020-02-15 07:24

Ok the problem was that I needed to call php-gtk as I had renamed it already

查看更多
登录 后发表回答