Reading album art using php-reader (zend) - php

I have been trying to use the Zend Id3v2 class (php-reader) to get the album artwork (apic) from an MP3, but it doesn't seem to want to work properly. Is there a different php-reader library available that has been proven to work?
Also, for some reason all of the require_once calls in the function are set to 'Zend/...' and not to an absolute path like require_once $_SERVER['DOCUMENT_ROOT'].'/Zend...', which breaks them because they are trying to get to a subfolder called 'Zend' in the current directory which is a sub directory of Zend. I also can't use Finder & Replace to set it to an absolute path without going through each file manually, as the files in this class are locked. SMH FACEPALM

Zend Framework 1 is written with the assumption that the folder where your Zend is stored is on the include_path.
e.g.
define('LIBRARY_PATH', __DIR__ . '/../library');
set_include_path(implode(PATH_SEPARATOR, array(
realpath(LIBRARY_PATH),
get_include_path(),
)));
This assumes that you're running this code in a sibling folder to library and that your Zend Framework files are in library/Zend

Related

Zend GData Include Paths

I'm attempting to write a simple script to read from and write to a Google Spreadsheet. I cannot seem to get the correct Zend include paths to work.
I began by using this walkthrough, kindly provided by a fellow developer:
http://www.farinspace.com/saving-form-data-to-google-spreadsheets/
I have been using different permutations of the location of the Zend GData library (downloaded directly from the Zend website), which claims it is supposed to work without the entire framework.
I have tried the following:
1) Zend library folder ZendGdata-1.12.17 right off the web root (since the code provided uses the following convention)
set_include_path(get_include_path() . PATH_SEPARATOR . "$_SERVER[DOCUMENT_ROOT]/ZendGdata-1.8.1/library");
I, of course switched the directory to the correct one, so that I use the following:
set_include_path(get_include_path() . PATH_SEPARATOR . "$_SERVER[DOCUMENT_ROOT]/ZendGdata-1.12.17/library");
This results in this message:
Fatal error: require_once(): Failed opening required 'Zend/Http/Header/HeaderValue.php' (include_path='.:/usr/lib/php5.5:/kunden/homepages/40/USERNAME/htdocs/network/ZendGdata-1.12.17/library') in /homepages/40/USERNAME/htdocs/network/ZendGdata-1.12.17/library/Zend/Http/Client.php on line 45
2) Putting the include path in a php.ini file.
3) Putting the include path in .htaccess
4) Using other set_include_path statements
5) Uploading the Xml folder to the Zend library folder (per another answer)
It seems that I can get the initial loader to load Zend, but in the Google_Spreadsheet.php file it loads several of the classes:
Zend_Loader::loadClass('Zend_Http_Client');
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Spreadsheets');
I've tried putting the Zend GData library into a directory on the same level as the webroot, and still get errors.
I do not have access to SSH or very much past simple control panel functionality (no include path access in php.ini).
Other answers I have looked at:
Zend Gdata include path issue (Loader.php)
Zend Framework include path
ZendGdata framework path set error
AND MANY MORE.
What would happen if you just create script.php in the folder where Zend folder is, so it looks like:
[Zend]
script.php
and inside script.php do this:
<?php
require_once(dirname(__FILE__).'/Zend/Loader/Autoloader.php');
$loader = Zend_Loader_Autoloader::getInstance();
$spreadsheet = new Zend_Gdata_Spreadsheets();
var_dump($spreadsheet);
will it instantiate Zend_Gdata_Spreadsheets object and dump it without errors?

Getting require_once in Zend to find files

I am new to ZEnd, any help is greatly appreciated
I had various contractors work on my site, and things got a messy, with multiple copies of the same folders in different locations. Now I am going in and trying to clean things up. FUN!!! One of the problem I am having is that the require_once statements in Zend are not finding the files they are looking for. I am having to go in and change the paths as follows. Assume that this is the code found in Zend/Gdata/App/FeedEntryParent.php
Not Working (Can't Find File):
require_once 'Zend/Gdata/App/Extension/Updated.php';
Seems to Work Fine:
require_once '/home/paul13/paul13.com/includes/library/Zend/Gdata/App/Extension/Updated.php';
The problem is that most of the require_once statements are writting like the first one. short of going in and manually editing all of them, is there a way to tell the require statements to look in the indicated directory? '/home/paul13/paul13.com/includes/library/' using php.ini? I tried entering
include_path=".:/home/paulthetutor/paulthetutors.com/includes/library"
in php.ini, but that does not seem to solve the problem.
The title of your question seems to have little to do with the content you've posted.
I had various contractors work on my site...are not finding the files
You've paid contractors to deliver code which doesn't work?
The problem is obviously that the path in the first
No - the problem is that your include paths are not set up correctly. If you're using an include path as a mechanism to avoid typing lots of stuff then you're doing it wrong. Your include path should not include entries pointing inside a directory tree maintained by someone else. Nor should you be changing this structure without a very specific and valid objective.
As a temporary workaround until you fix the include/require statements to what they should have been in the first place, then change your include path - either in php.ini, in httpd.conf, in .htaccess, via an auto-prepend or at the top of every script.
(BTW you're confusing folders with directories)
The folder you mentioned in the question is part of the Zend library. You can check if you have a library folder inside your Zend Framework project and whether it contains the file
'Zend/Gdata/App/Extension/Updated.php'
To include the entire ZF library, use the following code either in your public/index.php or in your Bootstrap.php file.
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
And yes, selectively remove the require statements one by one and locally copied versions of library files (after making sure that they do not have updated codes, ofcourse).
You might want to check the default Zend Framework application structure here to compare the folder structures.

PHP - Relative paths to included and required files

Well, i am working with a framework that is composed of a somewhat complex file and directory structure.
in my application, i just need to require a file, like so:
require "framework/mainfile.php";
inside mainfile, it is including other files, like:
include "framework/classes/class1.php";
....
and inside some class files it is including other files in the same way;
what i need is to change the location of the framework files and thus the relative path to the framework files in order to have something like
include "lib/framework/mainfile.php";
but i don't want to look in all the files and change the path in every one of them because i would always have to be doing it again when i change to a new version of the framework.
Is there any way of doing this?
use
set_include_path(implode(PATH_SEPARATOR, array(
realpath('Your/updated/path'),
get_include_path(),
));
so your current include paths will not be effected
and you will not need to make change in all files
You can use __DIR__ to get the absolute path of the directory the current script is in. You can then use:
include __DIR__ . '/classes/class1.php';

A redirection or file access problem about Zend Framework

I'm beginner at Zend Framework.
I have a php project with Zend 2.2.0 and PHP 5.2.4 but it cannot work truely.For ex at the staring point;
Failed opening required 'Zend_Loader_Autoloader.php'
but this php file is exist.
And maybe a helper point about solving problem, when I try to access a file in our project like http://localhost/application/default/views/scripts/login/index.phtml the file opens but there is no access javascript file like default_login.js.(and a similar situation about *.gif files etc.)
Firebug prints:
"http://localhost/application/default/views/scripts/login/%7B$VIRTUAL_DIR%7Dpublic/scripts/default_login.js" 404 not found.
However the correct url must be "http://localhost/public/scripts/default_login.js"
NOTE:The directory access permissions are ok, the problem is not that.
If Zend_Loader_Autoloader is not found then I suspect the Zend Framework library is not in the include path or inaccessible (permissions).
Also the 404 on .js and .gif files maybe down to your ModRewrite rules, have you changed the default .htaccess file at all?
edit :
Pretty sure this is going to end up be not including the ZF library in the includes path.
To check the include path use phpinfo() or just have a look at what is set in /public/index.php
It defaults to
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
I don't have my copy there as I installed using PEAR and it's already in my includes path

Using Zend_PDF in a stand alone mode, how to set the include of the land class

I'm writing a tiny school project in php. I needed to display some information in a pdf format and send the file via mail.
When i've copy the PDF folder with the pdf class file from the librairy.here is my folder structure
/
/lib
/Swift
/....
/Zend
/Pdf
Pdf.php
test_file.php
here is the content of test_file.php
require_once 'lib/Zend/Pdf.php';
$pdf = new Zend_Pdf();
$pdf->render();
and it's throwing this
( ! ) Fatal error: require_once() [function.require]: Failed opening required 'Zend/Pdf/Page.php' (include_path='.;C:\xampp\php\PEAR;C:\ZendFramework-1.10.8\bin;') in C:\xampp\htdocs\schoolproject\lib\Zend\Pdf.php on line 27
but i did notice that all classes includes by referring to the top Zend folder, even siblings classes ex :
require_once 'Zend/Pdf/Page.php';
i'm a little confuse about how to deal with that. I'm think about autoload feature or manually correct the require path to suit my project (which will be a pain).
What's the best way to go around it?
THanks for reading this.
Well, you need to configure your include path to the root of the Zend Framework library folder.
set_include_path(implode(PATH_SEPARATOR, array(
'c:\ZendFramework-1.10.8\library',
get_include_path(),
)));
As Zend uses pseudo namespaces, you need to include the toplevel directory library/ and not library/Zend
You may also want to use Autoloader
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
It avoids you to call require_once() each time you need to 'require' a file to load a Class
You have to register the ZF autoloader. After that you can just use the classes and the autoloader will figure out the rest.
$zf_path = 'PATH/TO/YOUR/LIB/FOLDER';
set_include_path($zf_path.PATH_SEPARATOR.get_include_path());
require_once($zf_path.'/Zend/Loader/Autoloader.php');
$loader = Zend_Loader_Autoloader::getInstance();
$loader->registerNamespace('Zend_');

Categories