how to install DB.php? - php

I have use DB::Connect in my program for accessing the database.
I ran my php program this shows the error
DB.php file is not their.
require_once 'DB.php';
PEAR::setErrorHandling(PEAR_ERROR_DIE);
Then I copy the DB.php file and PEAR.php file from another machine to my
machine after that If I ran from command line it didn't through the error.
while running from browser this shows error. How to solve this problem.?
How to install this DB.php?

PEAR provides a command line installer that should take care of all the details:
pear install DB
Since PEAR packages are mainly PHP code, you can also copy the files manually, but you must make sure you copy everything, not only the first required file, and your script must also be able to find the files so you must add pear to the include_path PHP directive.

Related

How to install joomla extension by command

I am trying to install extension by command.
In server already configure the PHP CLI and I'm using this code :
shell_exec('php-cli '.$SitefilePath.' --package='.$packagePath.'');
I have upload the file:
https://raw.githubusercontent.com/akeeba/vagrant/master/vagrant/files/joomla/install-joomla-extension.php
In the CLI folder and pass path as SitefilePath into command.
but its not working.
I have checked with all option :
http://www.php-cli.com/php-cli-options.shtml
Let me know how to get this work.
All of these issues have been properly debugged in the install-joomla-extension.php script I wrote.
First, create a new plain text file and paste that code in it. Save it as install-joomla-extension.php in your Joomla! site's cli directory. The name is not important, the location (cli directory) is.
Now you can call it like this:
cd /path/to/site/cli php ./install-joomla-extension.php --package=/where/is/your/extension.zip
The script returns one of the following exit statuses:
The extension was installed successfully.
The package file was not found.
The package file could not be extracted.
The extension could not be installed.
You can copy this file to your site's cli directory and install extensions and extension updates any time you want.
Source: https://www.dionysopoulos.me/238-installing-joomla-extensions-from-the-command-line.html
Let me know if this works.

Pipe email in PHP

I would like to pipe email through a PHP script.
To be recognized has a script to be execute by Shell, I've put that line a the begining of my file:
#!/usr/bin/php -q
I've enabled PHP's Mail Parse extension.
I have 2 issues:
If I move my script into a sub directory, any email can't be piped, despite of the new valid patch set in my c-panel (Seems like PHP IO stream can't be read in sub directories?). Otherwise, I can pipe email in /public_html (where my php.ini file is), but I'm still unable to call a Mail Parse's function that directory.
My script seems to use another php.ini file, because when I call a function from Mail Parse, PHP warns me that the function is undefined (if I use another script manually, in the same directory and same code, all works and there's no warning.). I've put that line to use a specific php.ini file #!/usr/bin/php -c /homeXX/XXXX/public_html/php.ini. It didn't worked.
Thanks for any answer, it'll be very appreciated.
Setting up stuff in your php.ini ist one thing.
I think you need to install pear/pecl and the mailparse package to make it work.
Depending on you linux flavor you can do that with (debian/ubuntu)
sudo apt-get install php-pear
sudo pecl install mailparse
and your php.ini needs the path to pear (if not already set) in
Path and Directories section.
take a look at the manual about mailparse
UPDATE: Depending of server configuration, you have to avoid space between command line option (-c) and path (/path/to/script). That solution worked in my case!

PHP: PEAR on windows tries to open c:\windows\pear.ini for writing even though the configuration file is c:\pear\pear.ini

On Windows, when I run
pear config-set auto_discover 1
I get the following error
PEAR_Config::writeConfigFile fopen('C:\Windows\pear.ini','w') failed (fopen(C:\Windows\pear.ini): failed to open stream: Permission denied)
even though I had mentioned during PEAR installation that my config file was c:\pear\pear.ini.
How to fix this, please (without running PEAR in admin mode or changing the permissions of c:\windows\pear.ini)? I guess my problem will be solved if I can figure out where PEAR is getting the directory for pear.ini from.
Thanks!
In the PEAR installation, when I got to the step of modifying the paths I changed the path for pear.ini from C:\Windows\pear.ini to $prefix\pear.ini and I still ran into this same error. Apparently the installation script did not update everything that it needed to.
Based on a comment on a bug report for PEAR (http://pear.php.net/bugs/bug.php?id=16939), I added an environment variable PHP_PEAR_SYSCONF_DIR to point to my PEAR install folder (C:\php\PEAR).
I am now able to successfully run the same config-set command that you were initially attempting to run.
Note the follow-on comment on the bug report however. I only needed one PEAR installation on my machine whereas you may need multiple installations.
I was able to fix this by opening the command prompt as administrator. This is done by right-clicking on the command prompt icon and selecting 'Run as Administrator'. Once command prompt is open, navigate to your php directory and run: php go-pear.phar again. Should run without an issue.
The issue is, when you open your command prompt, your current account doesn't have the privilege to write to your windows directory. Running your command prompt as administrator, will allow for writing to c:\windows
Hope this helps.

go-pear.bat file won't install PEAR at all

I just made a new install of WAMP on Windows 7 and I'm trying to get PEAR to work. Things are going wrong from the very beginning. When I try to execute the go-pear.bat file, it shows me this.
phar
"C:\wamp\bin\php\php5.3.1\PEAR\go-pear.phar"
does not have a signature Warning:
require_once(phar://go-pear.phar/index.php):
failed to open stream: pha r error:
invalid url or non-existent phar
"phar://go-pear.phar/index.php" in C:\
wamp\bin\php\php5.3.1\PEAR\go-pear.phar
on line 1236 Press any key to continue
. . .
How can I help it that the file doesn't have a signature?
This blog-post might interest you : Pear: “go-pear.phar” Does Not Have a Signature
It explains how to change a configuration option in php.ini to avoid this error message, and what's said it for WAMP 2.0 and PHP 5.3, so might work in your case.
Just in case anyone comes here from Google: We fixed the .phar download yesterday on http://pear.php.net/go-pear.phar.
In some circumstances (well, actually only on Windows :-)) the file could corrupt from the download. So for example, a lot of people wanted to download it and ended up copy-pasting the contents, etc..
We've asked some people on Windows to test and so far it worked for everyone I talked to. Let me know if it works for you.
Let’s try this from the PEAR directory. cd PEAR and let’s try that again.
php.exe -d phar.require_hash=0 go-pear.phar
Now the PEAR install runs fine.
If the go-pear.bat file won't run, try this procedure:
issue this command with cmd.exe:
php -d phar.require_hash=0 go-pear.phar
Allow the installer to edit php.ini.
Check the contents of PEAR_ENV.reg - located in the PEAR directory YOUR-PHP-INSTALL-PATH\PEAR\ folder (ex. c:\PHP\PEAR\PEAR_ENV.reg) to be sure it has the paths right. Edit as needed and run it. Check your path and environment variables for correctness, then do the same in go-pear.bat and php.ini (mine needed to be corrected to point correctly to my php.exe file).
Issue the
pear
command at the command line to test the path configuration. It will run and do everything but still can't install packages due to a missing dependency.
Download and uncompress Structures_Graph from the PEAR website (direct link).The file has three folders - docs, Structures and tests. Copy the Structure folder into the YOUR-PHP-INSTALL-PATH\PEAR\ folder (ex. c:\PHP\PEAR\Structures).
Issue the command:
pear install Structures_Graph
Even though the files are present, Structures_Graph is not really installed unless you issue the above command.
Issue the command:
pear update PEAR
Enjoy!
Good luck and thanks to Marcos Roriz for the graph dependency half of my solution!

Getting PEAR to work on XAMPP (Apache/MySQL stack on Windows)

I'm trying to install Laconica, an open-source Microblogging application on my Windows development server using XAMPP as per the instructions provided.
The website cannot find PEAR, and throws the below errors:
Warning: require_once(PEAR.php) [function.require-once]: failed to open stream: No such file or directory in C:\xampplite\htdocs\laconica\lib\common.php on line 31
Fatal error: require_once() [function.require]: Failed opening required 'PEAR.php' (include_path='.;\xampplite\php\pear\PEAR') in C:\xampplite\htdocs\laconica\lib\common.php on line 31
PEAR is located in C:\xampplite\php\pear
phpinfo() shows me that the include path is .;\xampplite\php\pear
What am I doing wrong? Why isn't the PEAR folder being included?
You need to fix your include_path system variable to point to the correct location.
To fix it edit the php.ini file. In that file you will find a line that says, "include_path = ...". (You can find out what the location of php.ini by running phpinfo() on a page.) Fix the part of the line that says, "\xampplite\php\pear\PEAR" to read "C:\xampplite\php\pear". Make sure to leave the semi-colons before and/or after the line in place.
Restart PHP and you should be good to go. To restart PHP in IIS you can restart the application pool assigned to your site or, better yet, restart IIS all together.
If you are using the portable XAMPP installation and Windows 7, and, like me have the version after they removed the XAMPP shell from the control panel none of the suggested answers here will do you much good as the packages will not install.
The problem is with the config file. I found the correct settings after a lot of trial and error.
Simply pull up a command window in the \xampp\php directory and run
pear config-set doc_dir :\xampp\php\docs\PEAR
pear config-set cfg_dir :\xampp\php\cfg
pear config-set data_dir :\xampp\php\data\PEAR
pear config-set test_dir :\xampp\php\tests
pear config-set www_dir :\xampp\php\www
you will want to replace the ':' with the actual drive letter that your portable drive is running on at the moment. Unfortunately, this needs to be done any time this drive letter changes, but it did get the module I needed installed.
I tried all of the other answers first but none of them seemed to work so I set the pear path statically in the pear config file
C:\xampp\php\pear\Config.php
find this code:
if (!defined('PEAR_INSTALL_DIR') || !PEAR_INSTALL_DIR) {
$PEAR_INSTALL_DIR = PHP_LIBDIR . DIRECTORY_SEPARATOR . 'pear';
}
else {
$PEAR_INSTALL_DIR = PEAR_INSTALL_DIR;
}
and just replace it with this:
$PEAR_INSTALL_DIR = "C:\\xampp\\php\\pear";
I restarted apache and used the command:
pear config-all
make sure the all of the paths no longer start with C:\php\pear
I fixed
avast deletes your server.php in your directory
so disable the antivirus
check the (server.php) file on your laravel folder
server.php
<?php
/**
* Laravel - A PHP Framework For Web Artisans
*
* #package Laravel
* #author Taylor Otwell <taylor#laravel.com>
*/
$uri = urldecode(
parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
);
// This file allows us to emulate Apache's "mod_rewrite" functionality from the
// built-in PHP web server. This provides a convenient way to test a Laravel
// application without having installed a "real" web server software here.
if ($uri !== '/' && file_exists(__DIR__.'/public'.$uri)) {
return false;
}
require_once __DIR__.'/public/index.php';
AS per point 1, your PEAR path is c:\xampplite\php\pear\
However, your path is pointing to \xampplite\php\pear\PEAR
Putting the two one above the other you can clearly see one is too long:
c:\xampplite\php\pear\
\xampplite\php\pear\PEAR
Your include path is set to go one PEAR too deep into the pear tree. The PEAR subfolder of the pear folder includes the PEAR component. You need to adjust your include path up one level.
(you don't need the c: by the way, your path is fine as is, just too deep)
On Windows use the Xampp shell (there is a 'Shell' button in your XAMPP control panel)
then
cd php\pear
to go to 'C:\xampp\php\pear'
then type
pear
Try adding the drive letter:
include_path='.;c:\xampplite\php\pear\PEAR'
also verify that PEAR.php is actually there, it might be in \php\ instead:
include_path='.;c:\xampplite\php'
Another gotcha for this kind of problem: avoid running pear within a Unix shell (e.g., Git Bash or Cygwin) on a Windows machine. I had the same problem and the path fix suggested above didn't help. Switched over to a Windows shell, and the pear command works as expected.

Categories