I want to do this to be able to take advantage of Gedmo translatable to translate values in my tables. I already have Doctrine working in my project, but I don't know how to add these extensions : doctrine extensions
I am using ZF Boilerplate and apparently it should be fairly simple, but I am lost. Any ideas?
Add namespace:
autoloaderNamespaces.app[] = "Gedmo"
Add event subscriber:
resources.doctrine.dbal.connections.default.eventSubscribers[] = "Gedmo\Translatable\TranslatableListener"
Add annotation driver:
resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationNamespaces.0.namespace = "Gedmo"
resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationNamespaces.0.includePath = APPLICATION_PATH "/../library"
I realize this was posted some time ago, and this might be a shot in the dark, but adding these two lines to my application.ini config did the trick for me:
resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationNamespaces.0.namespace = "Gedmo"
resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationNamespaces.0.includePath = APPLICATION_PATH "/../library/vendors"
Hope this helps someone!
Related
I did already tried approach of zend framework 1. I did place this code of line in my application.ini file which is this
resources.session.use_only_cookies = true
resources.session.save_path = "/tmp"
resources.session.remember_me_seconds = 864000
resources.session.cookie_httponly = true
resources.session.cookie_secure = On
resources.session.name = "SOMEOTHER"
But it does not working still name is showing "PHPSESSID".
I am attaching a screen shot for your reference.
Thanks is advance.
I did resolve this issue
We don't need to do major thing.
1. Just Install Zend Session Library in project folder.
2. Include/Use Installed library (use Zend\Session\Config\SessionConfig), Create a function "_initSession" in Zend Bootstrap.php file
3. And write this line of code
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions(array('name' => 'SOMEOTHER'));
I'm writing to see if someone of you guys has encountered this problem before and have a chance to understand why it happened to me.
This is the story.
I developed many ZF applications before Zend Framework v. 1.8, then I've stopped for about 18 months. Now I had to start a new project on which I decided to use Zend Framework again.
On my local server I had the version 1.11.3 installed, so I didn't download the latest release.
Before the use of Zend_Application with the Bootstrap.php file I used to start sessions putting my session options in my config.ini file and then loading them into a Zend_Session instance like this:
config.ini
sessions.name = NAME
sessions.use_only_cookies = 1
sessions.save_path = APPLICATION_PATH "/../tmp/sessions"
sessions.strict = on
sessions.remember_me_seconds = 1800
index.php (into the public webserver directory) before starting the application:
Globals::startSession();
custom Globals class with various useful methods:
class Globals
{
static public function startSession()
{
$sessions_conf = self::getConfig()->sessions;
Zend_Session::setOptions($sessions_conf->toArray(););
Zend_Session::start();
}
}
This has always worked very well, enabling my sessions (used with Zend_Session_Namespace) and storing the session files in the save_path.
With Zend_Application the manual tells to simply store the session options in the application.ini file under the "section" resources and Zend_Session will be configured automatically...
I did it like this:
; SESSIONS
resources.session.name = NAME
resources.session.use_only_cookies = 1
resources.session.save_path = APPLICATION_PATH "/../tmp/sessions"
resources.session.strict = on
resources.session.remember_me_seconds = 1800
It didn't worked.
So I tried to use (not at the same time!) the _initSession() and _initForceSession() methods in the Bootstrap.php file, putting them at the beginning of the class and writing into them the code:
$this->bootstrap('session');
But session were never working, data were not stored between http requests and session files were never written into the save_path...
Could anyone, please, let me know if this is a normal behaviour (maybe I have missed something somewhere...)?
Obviously I solved the problem re-implementing my older method (and it works perfectly), but I would like to learn how to use it correctly.
Thanks in advance.
This should be a case of turn it on and it works, might have made it to easy.
I think you may have a problem with how you set your options in your application.ini:
; SESSIONS
resources.session.name = NAME
resources.session.name.use_only_cookies = 1
resources.session.name.save_path = APPLICATION_PATH "/../tmp/sessions"
resources.session.name.strict = on
resources.session.name.remember_me_seconds = 1800
according to the reference manual
To set a session configuration option, include the basename (the part
of the name after "session.") as a key of an array passed to
Zend_Session::setOptions().
with your options set correctly the bootstrap _initSession() should just work.
public function _initSession()
{
Zend_Session::start();
}
P.S. I use Zend_Session_Namespace all the time but rarely deal with a global session.
In your Bootstrap.php add
public function _initSession()
{
Zend_Session::start();
}
session options can be set in application.ini
the thing is these this lines:
$loginUrl = $this->view->url(array('controller'=>'auth', 'action'=>'index'));
$registerUrl = $this->view->url(array('controller'=>'register', 'action'=>'index'));
based on rob allens' Zend_Auth login/logout tutorial (win7/apache),
are placed in a view helper, and this one:
echo $this->url(array('controller'=>'index','action'=>'add'));
is placed in the index view script.
The generated links Do work fine in LOCAL, but in REMOTE only the 3rd line works.
ANY IDEAS? Where should i look for this? wich way to follow?
I was tempt to think in the remote server conf but the 3rd line works fine, so..
thanks!
Try this helper instead of view Zend_Controller_Action_Helper_Url:
//simple($action, $controller = null, $module = null, array $params = null)
//so your lines will look like:
$loginUrl = $this->_helper->url->simple('index','auth');
$registerUrl = $this->_helper->url->simple('index','register');
P.S. your lines work properly on Win7 and Ubuntu servers check registry of the lines
I found out that was the server. (.htacces and mod_rewrite) was not included in the package.
I think the third line was working because it was in the index controller, but when calling the others, then happened the object not found.
To work out this, i found an example using zend debug (was in german) so i inferred it (and then wrote to the hosting service), but still not quite sure how to check (phpinfo?) if a host have this features available or not in your package.
How do set up autoloading with Doctrine 2 and Zend to load entities in the following directory structure:
Application
-Modules
--Core
---Models
----Entities
----Repositories
--CMS
---Models
----Entities
----Repositories
I want to be able to load classes using {ModuleName}\Entities{EntityName}. For example, I'd like to be able to do this to load a 'User' entity:
$em->getRepository('Core\Entities\User');
or something like this for a 'Pages' entity:
$em->getRepository('CMS\Entities\Pages');
I can set it up to load 'CMS\Models\Entities\Pages' but I'd like to be able to know how to do it without having to map directly to the directory structure. Is this possible?
I don't how you glue Zend Framework and Doctrine2 together but if you are using the popular Bisna glue (which is pretty cool) you can set-up more than one mapping directory in your application.ini. Take a closer look to the following ini settings:
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.adapterClass = "Doctrine\ORM\Mapping\Driver\AnnotationDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingNamespace = "Core\Entities"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingDirs[] = APPLICATION_PATH "/modules/Core/Entities"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderCache = default
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.1.adapterClass = "Doctrine\ORM\Mapping\Driver\AnnotationDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.1.mappingNamespace = "CMS\Entities"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.1.mappingDirs[] = APPLICATION_PATH "/modules/CMS/Entities"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.1.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.1.annotationReaderCache = default
Something like the above would be accomplish what you want. If want to be able to do this fully automatically I think you have to patch the Bisna\Doctrine\Container class. Which for instance looks to the modules defined check if there is a entities directory and add's this to the doctrine entity manager.
Bisna
If you don't have a clue what Bisna is, this is a small library which allows you to easily 'glue' Doctrine2 and Zend Framework 1 together.
By watching this video it should be easy for you to understand how to integrate Doctrine2.
http://www.zendcasts.com/unit-testing-doctrine-2-entities/2011/02/
Please be aware that the Bisna version used in the video only supports Doctrine 2.0 and not 2.1 in that case you should use this one: https://github.com/guilhermeblanco/ZendFramework1-Doctrine2
i see everyone using this:
Doctrine_Manager::getInstance()
when i do this, its error is:
Class 'Doctrine_Manager' not found
how do i load this ?so that i can start get instances from doctrine manager?
i want to load this:
$con = Doctrine_Manager::getInstance()->connection();
$st = $con->execute("...............");
$result = $st->fetchAll();
where can autoload this , so i can call the getInstance() function from anywhere?
thanks...
Doctrine_Manager is part of version 1.2, not 2. If you are actually using 1.2, you need to let the autoloader know to load classes under the Doctrine_ prefix.
To do so, add this to your application configuration file...
autoloaderNamespaces.Doctrine = "Doctrine_"
You also need to ensure the doctrine classes can be found on the include path. If they aren't in your "library" folder or otherwise part of the include_path directive, add this...
includePaths.Doctrine = "/path/to/Doctrine-1.2/lib"
I think you might be looking for the EntityManager?
If so, here you can find a tutorial how to configure.
Also there is a library call Bisna for integrating ZF+Doctrine2, here is a good tutorial video for configuring it