Autoloader zend - php

Problems with require_once 'Zend/Library/Autoloader.php'
PHP Warning: require_once(Zend/Loader/Autoloader.php): failed to open stream: No such file or directory in /var/www/DenisApp/scripts/load.sqlite.php on line 13
PHP Fatal error: require_once(): Failed opening required 'Zend/Loader/Autoloader.php' (include_path='/var/www/DenisApp/application/../library:.:/usr/share/php:/usr/share/pear') in /var/www/DenisApp/scripts/load.sqlite.php on line 13
I have no idea what to do ! Please help ...

Download the correct Zend-version that your load.sqlite.php expects (can't find much about it, but it looks like the 1.x-range): http://framework.zend.com
Place the Zend-folder (located in the folder library in the Zend-download) in /var/www/DenisApp/application/../library
Hit F5

Download the latest framework (actually 'Zend Framework 2.3.1 Full'):
http://framework.zend.com/downloads/latest
Extract it to a folder near your application. Ie: /home/app/public_html/
Then prepare the Path in your php code:
set_include_path('/home/app/public_html/ZendFramework-2.3.1/library');
So you can use the Autoload class to initialize the framework:
$loader = new Zend\Loader\StandardAutoloader(array('autoregister_zf' => true));
$loader->register();
So you can call the classes you need. Example:
$mail = new Zend\Mail\Storage\Maildir(array('dirname' => "/path/to/maildir"));

Related

How to install Zendframework 1 in xampp

So i'm new in zendframework and i want to try zf version 1 , i cannot find a good documentation for this. i'm having an error when i try to run the downloaded file in xampp
here's the screen shot of my folder structure
I install zend framework using composer zendframework/zenframework
then here's the error
Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in D:\xampp\htdocs\Zend\public\index.php on line 17
Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='D:\xampp\htdocs\Zend\library;D:\xampp\php\PEAR') in D:\xampp\htdocs\Zend\public\index.php on line 17
you should read and understand step-by-step from here :
https://framework.zend.com/manual/1.11/en/learning.quickstart.create-project.html
Or,
https://framework.zend.com/manual/1.12/en/learning.quickstart.html
first try to understand the application structure.
As you are new in Zend framework, I think this is the best place to start.

Trouble with loading phar file

I’m interested in trying cloudconvert with php, but I can’t get it to work. I put the phar file in the same folder as index.php but when I’m running this code I get the error message below.
What’s wrong?
<?php
require 'phar://cloudconvert-php.phar/vendor/autoload.php';
use \CloudConvert\Api;
$api = new Api(“my_api_key”);
Warning: require(phar://cloudconvert-php.phar/vendor/autoload.php):
failed to open stream: phar error: invalid url or non-existent phar
"phar://cloudconvert-php.phar/vendor/autoload.php" in
/Library/WebServer/Documents/index.php on line 2
Fatal error: require(): Failed opening required
'phar://cloudconvert-php.phar/vendor/autoload.php' (include_path='.:')
in /Library/WebServer/Documents/index.php on line 2
I'm not into cloudconvert but this is what I read ...
You actually not loading a phar ... You try to load the autoload.php...
Assuming cloudconvert-php.phar/vendor/autoload.php is your full path
your should do:
require('cloudconvert-php.phar/vendor/autoload.php')

vendor/autoload.php: failed to open stream

I worked with a project using composer.But when i run the index file,system shows the following error,
Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in D:\xampp\htdocs\instagram_php\index.php on line 5
Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.;D:\xampp\php\PEAR') in D:\xampp\htdocs\instagram_php\index.php on line 5
I have installed composer from https://getcomposer.org/.
What am doing wrong?
You are using require_oncewith a relative path. It is possible but there are so many things that can go wrong that I usually avoid it.
Where is the vendorfolder relative to index.php? I recommend using an absolute path. You can use the magic constants to determine it:
require_once(__DIR__ . '/vendor/autoload.php');
NOTE: you can use /.. to go up the directory tree.
NOTE2: __DIR__ requires php 5.3 or higher. You can use dirname(__FILE__) for older versions.
Make sure vendor folder is there if not please Run following command:-
composer install

Require_once(Net/URL2.php): failed to open stream: no such file or directory

I installed the pear/http_request2 version 2.2.1 using Composer in my project but when I am trying to make my first request I am getting this Warning and Fatal error:
Warning: require_once(Net/URL2.php): failed to open stream: No such
file or directory in
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
on line 24
Fatal error: require_once(): Failed opening required 'Net/URL2.php'
(include_path='/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/pear_exception:.:/Applications/XAMPP/xamppfiles/lib/php')
in
/Applications/XAMPP/xamppfiles/htdocs/jet/vendor/pear/http_request2/HTTP/Request2.php
on line 24
I appreciate any help on how to fix it, thanks in advance.
David.
This should work:
composer require pear/http_request2:2.2.1
By default pear/net_url2 should be installed which has the required URL2.php file (./vendor/pear/net_url2/Net/URL2.php).
Then make sure you're including vendor/autoload.php file in your scripts to load automatically the include paths (see: vendor/composer/include_paths.php file).
Here is a simple PHP command to test this out:
php -r 'require_once "vendor/autoload.php"; require_once "Net/URL2.php";'
Note: The above command should run without any errors.
Related: Errors in the autoloaded HTTP/Request2 code, how to troubleshoot composer?
You need HTTP_Request2 from git master, because it has not been released/tagged yet at the time of writing.

Zend - error in index.php - not opening Zend/Application.php

I have a project written in PHP, in zend framework. But when i go on page: localhost/Project/public, i get an error:
Warning: require_once(Zend/Application.php): failed to open stream: No such file or directory in /var/www/Project/public/index.php on line 18 Fatal error: require_once(): Failed opening required 'Zend/Application.php' (include_path='/var/www/Project/library:.:/usr/share/php:/usr/share/pear') in /var/www/Project/public/index.php on line 18
The line 18 in file index.php is following:
require_once 'Zend/Application.php';
I have set include_path in php.ini:
include_path = ".:/usr/share/php:/usr/local/ZendFramework/library"
Zf project is successfully creating by commands from console, so i think that Zend is well configured (anyway in php.ini).
Help me! What I'm doing wrong?
You can see the include path it's using in the error, and it doesn't include /usr/local/ZendFramework/library. Typically index.php overrides the include path to point it at the project's library folder. So either you want a copy of ZF in the library folder, or if you prefer to keep ZF in /usr/local/ you want to edit this include path to point at /usr/local/ZendFramework/library as well.

Categories