I'm trying to create Configuration:
$config = new \Doctrine\ORM\Configuration;
Although I can see this class using Open declaration in Zend Studio running it in browser results in:
Fatal error: Class 'Doctrine\ORM\Configuration' not found in C:\Program Files\Zend\Apache2\htdocs\MyProject\library\Custom\Entitymanager.php on line 20
Make sure doctrine is in the include path and you have autoloadernamespaces[] = "Doctrine" in application.ini file
Doctrine has a nice autoloader:
require '/path/to/libraries/Doctrine/Common/ClassLoader.php';
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine', '/path/to/libraries');
$classLoader->register(); // register on SPL autoload stack
Also see the similar questions:
Integrating ZF/Doctrine2: Where do i put my Models/Entities & Proxy classes
ZF + Doctrine 2 on SO
Related
I have to continue on an already existing CodeIgniter 3 application (not written by me) which contains multiple applications for different customers, the project structure looks a little like this:
root/
applications/
customer1/
config/, controllers/, models/, views/, ...
third_party/
SimpleSAMLphp/
config/, metadata/, www/, ...
lib/
_autoload.php
customer2/
...
assets/, bundle/, ...
customers/
customer1/
assets/, index.php, ...
customer2/
...
system/
vendor/
composer/
autoload.php
Now for one of the applications I have to replace the ion_auth system with an SSO (setup as a Service Provider from their IdP metadata). I googled a lot and tought SimpleSAMLphp would be my best option.
But I am really struggling just even putting the SimpleSAMLphp SP API into my application and the documentation isn't great.
-I "include_once" the third_party/SimpleSAMLphp/lib/_autoload.php file in the customers/customer1/index.php file (before require_once BASEPATH...)
-I modified third_party/SimpleSAMLphp/lib/_autoload.php so it finds the vendor/autoload.php file
I expect to be able to use the methods of the SimpleSAMLphp library but instead I get the following errors:
-If I follow the code in this guide:
Fatal error: Call to undefined function SimpleSAML\Auth\Simple()
-If use include APPPATH . 'third_party\SimpleSAMLphp\www\index.php in my controller just above the code from above tutorial:
Fatal error: Class 'SimpleSAML\Error\Assertion' not found in
What am I doing wrong in my setup?
I am building a rest API with Web API2, Owin 3 and NInject Owinhost for my DI.
Using the example provided by NInject, by which I create an "HttpConfiguration" object and call the NInject extension methods in startup.cs, I get an error:
Error activating HttpConfiguration
More than one matching bindings are available.
Matching bindings:
1) binding from HttpConfiguration to method
2) self-binding of HttpConfiguration
3) binding from HttpConfiguration to constant value
Activation path:
1) Request for HttpConfiguration
Suggestions:
1) Ensure that you have defined a binding for HttpConfiguration only once.
My code is as follow in Startup.cs:
public void Configuration(IAppBuilder app)
{
Logger.Info("Entering Startup");
config = new HttpConfiguration();
ConfigureOAuth(app);
// Web API configuration and services
config.SuppressDefaultHostAuthentication();
config.Filters.Add(new HostAuthenticationFilter("Bearer"));
// Web API routes
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new {id = RouteParameter.Optional}
);
var appXmlType =
config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(
t => t.MediaType == "application/xml");
config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);
app.UseNinjectMiddleware(CreateKernel);
app.UseNinjectWebApi(config);
app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);
Logger.Info("Exiting Startup");
}
public static StandardKernel CreateKernel()
{
kernel = new StandardKernel();
kernel.Load(Assembly.GetExecutingAssembly());
kernel.Bind<HttpConfiguration>().ToSelf().Named("TestHttpConfiguration");
return kernel;
}
The strange thing is when I refresh the page in the browser, the error goes, which leads me to believe that this happens at application startup only.
So I'm confused with this. Has anyone faced the same issue with it?
Thanks
Vincent
I had this same error, as for some reason I had installed both Ninject.Web.WebApi.WebHost and Ninject.Web.WebApi.OwinHost.
If you look in source for OwinWebApiModule.cs and WebApiWebHostModule.cs, both Ninject modules have a binding for HttpConfiguration.
I removed the one I didn't need and things worked.
UPDATE
After trying everything, I managed to get it to work by... Starting a new project from scratch. I had the luxury of doing this because it is a new proof of concept for me.
The main difference here is I installed the packages required (owin 3, ninject) using the Package Manager console rather than the UI. I followed this link here to install those packages.
I then noticed an error message on one of the package as it was looking for Owin 2 dependencies and could not find any. I forced it to install using -DependencyVersion Highest as parameter and it was working fine from the outset.
Unless I missed it I didn't see this error when I installed the packages using the UI. Is it possible the package didn't install properly previously on my other project? Not sure.
Hope this helps someone.
I already integrated zf 1 with doctrine 2
I created entities by this:
php doctrine.php orm:convert-mapping --force --from-database annotation C:/wamp/www/ip/application/models
now I'm going to create getter and setter for them and generating entities I get the errors no metadata classes to process
php doctrine.php orm:generate-entities --generate-annotations="true" C:/wamp/www/ip/application/models
1- In the entity files generated, you need to delete this line:
"use Doctrine\ORM\Mapping as ORM;"
2- and also delete all appearances of ORM\
Just delpoyed my symfony website to the production server and I am getting this issue:
Anyone wonder what's up ?
require_once(/home/vsource4/www/students/lib/vendor/symfony-1.4.14/symfony-1.4.14/lib/autoload/sfCoreAutoLoad.class.php) [function.require-once]: failed to open stream:
No such file or directory in /home/vsource4/www/students/sfproject/config/ProjectConfiguration.class.php on line 4
This is not the case, because my symfony installation does exist here:
/home/vsource4/www/students/lib/vendor/symfony-1.4.14/symfony-1.4.14/
Now what can be a good reason herE?
<?php
require_once('/home/vsource4/www/students/lib/vendor/symfony-1.4.14/symfony-1.4.14/lib/autoload/sfCoreAutoload.class.php');
sfCoreAutoload::register();
class ProjectConfiguration extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins('sfDoctrinePlugin');
$this->setWebDir('/home/vsource4/www/students/sfprojects/web');
// $this->setWebDir($this->getRootDir().'/web');
}
}
I have used absolute paths, the paths are correct.
thanks
Tried clearing the symfony cache?
I have a problem using modules in ZendFramewok. I have so far created the directory sturucture for modules in application directory.
Application
--configs
--Bootstrap.php
--modules
----default
------controllers
--------ErrorController.php
--------IndexController.php
------models
------views
--------helpers
--------scripts
----------error
------------error.phtml
----------index
------------index.phtml
Updated application.ini by adding the following lines:
resources.frontController.moduleDirectory = APPLICATION "/modules"
resources.module[] = ""
Setup Virtual host for public as ServerName.local
So if type in browser Servername.local I get the default view, but if I type Servername.local/:default/:index/:index I get a 403(Forbidden), if I type Servername.local/default/index/index I get a 404(Not Found), any help??
I believe your missing an "s" on resources.module[], might want to update that to:
resources.modules[] = ''
First of all check if mod_rewrite enabled and configured in .htaccess. I believe this 404 error coming from server and not from your application.
After that check your index controller defined as followed: Default_IndexController extends Zend_Controller_Action
If this is not your issue i'll throw in more suggestions.