Zend Framework path to helpers - zend-framework

fopen(C:/xampp/htdocs/adv/application/views\helpers/Layout.php) how to fix this path?
And why does ZF is searching for bundled helpers in this folder and not in zend library folder?
By the way, here path is fine, but still searching in wrong folder
fopen(C:/xampp/htdocs/adv/application/controllers/helpers/ViewRenderer.php)

ZF searches in these paths, because they are the default paths.
From the ZF Reference Guide on View Helpers
Note: Default Helper Path
The default helper path always points to the Zend Framework view helpers, i.e., 'Zend/View/Helper/'. Even if you call setHelperPath() to overwrite the existing paths, this path will be set to ensure the default helpers work.
The second path is for ActionHelpers (as indicated by ViewRenderer) and is the default path as well. It is hardcoded into Zend_Controller_Action_HelperBroker::getPluginLoader().
The ViewHelper path doesn't have to be fixed. PHP knows how to handle directory separators, so it doesn't matter whether is is a slash or a backslash.
See the linked question and answers on how to add additional helper paths.

Related

direct routing to TYPO3 extension files

I am a maintainer of the TYPO3 extension QFQ.
Our extension accesses many of its files directly by links relative to index.php of TYPO3. For example it requests the following API file via JavaScript in the frontend:
/typo3conf/ext/qfq/Classes/Api/file.php
Since the upgrade to spoken URLs with TYPO3 v9 these relative paths stopped working. For example the above relative path would result in the following url when clicked on in the browser:
example.com/en/.../typo3conf/ext/qfq/Classes/Api/file.php
instead of:
example.com/typo3conf/ext/qfq/Classes/Api/file.php
We have seen that one can add static routes to single files in the TYPO3 backend (Sites > Edit > Static Routes > Create new) but this does not seem to allow us to set the whole extension directory /typo3conf/ext/qfq as a static route. Since many files are accessed this way, it is way too tedious to set a static route for every single fie on every installation of TYPO3 which uses our extension.
Our own "dirty" solution to this problem would be to add a new rewrite rule to the .htaccess which rewrites any url containing typo3conf/ext/qfq. It would remove any path before typo3conf.
My question is: Is there a better way to solve this problem? How do other extensions create links directly pointing to the files inside the extension directory? Are we missing something obvious?

Typo3 - Images aren't found on "sub paths" (no absolute path)

I wrote a Typo-3 template which is working fine the problem is that when I call a "sub path" the image links aren't found anymore.
/index.php: every thing works fine
/test/index.php: images aren't found anymore
The problem is that no image url is an absolute path whether from TypoScript or from fileadmin via component.
Is there a way to force absolute path use everywhere?
I assume you use an extension to get nice URLs (coolUri or realUrl) so you get path segments for each page other than the root page.
So you have subfolders in your URL but always the index.php from your webroot is called.
Now you have images which by default are referenced relative to the working php script. As the working php script is /index.php a path to fileadmin/img/image1.jpg is correct.
But your browser thinks you are in path /test and requests an image <domain>/test/fileadmin/img/image1.jpg, which does not exist.
Either your browser needs to know which base to use for server pathes (setting base Url),
or (better) you provide absolute URLs for any resources. This can be done with a little typoscript configuration:
config.absRefPrefix = /

TYPO3 Change extension builder default extension location path from typo3conf/ext to some other path

I use extension builder for creating my extensions in TYPO3 V 6.1.1. The default location where the extensions are stored is in typo3conf/ext/ folder.
I would like to change this location to some other path, say /MyExtensions/MyExtName. From this location I'll give symbolic links to ext/ folder.
The problem is changing the default location of extensions from typo3conf/ext/ to /MyExtensions/MyExtName.
How do I do this ?
EDIT
Is it possible to create a directory MyExtensions under typo3conf/ext/ and then MyExtensions will contain all my custom-made extensions. It's just that it'd be easy to have extensions organized this way. My custom extensions would be in typo3conf/ext/MyExtensions/MyExtOne , typo3conf/ext/MyExtensions/MyExtTwo etc...
That's not possible. Also do not try to circumvent the default typo3 paths but learn to live with them.
Create/Save the extension and copy&paste the content to the location you want to have them. Then create the symlink back to typo3conf/ext. It doesn't matter where the ExtensionBuilder writes the files when the target points to an other directory.

Fatal error: Class 'Zend_Form' not found

I've started using Zend framework, and Im following this simple Zend form tutorial. The form is located in application/forms directory I have included the Zend framework in the Path (by going to computer properties). However when i access form.php page, i get this error:
Fatal error: Class 'Zend_Form' not found
I have also tried by copying the Zend folder from the Zend framework in the library folder of the application, however error still remains same. Thanks.
It sounds like you are confusing two notions: the system path and the include path.
The system path is an operating system concept. When you ask the OS to execute a command, the system path is a list of places to look for the executable.
In contrast, the include path is a PHP concept that tells PHP a list of folders in which to look for files invoked by PHP include/require statements.
Any path that you find in "Computer > Properties" is almost certainly the OS-level system path. What you need to do is to make sure the Zend folder on the PHP include path, either by moving the Zend folder or by modifying PHP's include path to include a point to the Zend folder.
In a typical ZF app, the include folder is set in index.php (the front controller). So, the only explanation for not finding Zend_Form is that the autoloader is not being instantiated.
If you are using Zend_Application, this happens automatically. However, it seems like you are bypassing public/index.php and the whole Zend_Application instantiation by trying to directly "access" a file called form.php directly. If this file contains only the definition of your form (extending Zend_Form), then the absence of autoloading could easily explain the error message you are getting.
I'd try instantiating the form in a controller action, by which time in the request processing cycle, the autoloading is probably already in place.
[At that point, given the file locations you cite, we might run into a resource-loader issue, but that's a somewhat different issue that can be handled by instantiating a Zend_Application_Module_Autoloader in your Bootstrap.]
It looks like you do not use Zend_Loader. You should focus on it.
You can also manually in your custom form class include Zend_Form class.

How should I set up my application when I can't change the document root?

I don't have permission to change the document root the /public/ directory so how should I set up my Zend Framework application to run from the current root directory? Using the Zend Framework 1.8 command line tool, I don't know if there is a way to tell it to create a directory structure this way.
If you can access only the upper level of web (i.e. - public), you should set index there and the whole application folder too. Create a .htaccess with
Deny from all
And put it into your /application.
Your configuration will be:
/application
/library
index.php
The simplest way without changing a lot of configuration, is to put everything in the public folder you mention into your public_html folder, then place all the other contents, like the application, and library folders into the directory up from public_html.
You can also throw everything into your public_html folder, although that is not recommended. Each class has options to provide a different path. For example on the Front_Controller, you can set the Controllers directory to wherever you want. There are options to specify different paths, but if you follow convention it is done for you.
Just use the quickstart guide and adjust according to it. Zend_Tool is still experimental anyway. Let me know if this helps.
So here's what I ended up doing:
Download the Quickstart sample code.
Move everything in public up to the main directory, along side application, library directories.
Alter include paths to library and application in index.php to point to the correct locations
I think that was all I had to do. ZF new how to the rest.
I don't think this is ideal however, as already mentioned, application directory becomes accessible from the web, but for now, it's getting the job done.