zend framework 2 projects conflict - zend-framework2

I have a home server with 2 sites zf2 plus doctrine in a structure like this: var/www/site1 and var/www/site2 i think i have a conflict with namespaces. On one of two projects(site1) i receive:
Fatal error: Cannot redeclare class Doctrine\Common\Annotations\Annotation\Target in /var/www/site2/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/Annotation/Target.php on line 31
what should i do to not try to load classes from other project?
Tank u.

So after a while i figure out what goes to this, is opcache from php, once i disable all zf2 project goes well. i don't know how to adjust to work with opcache enable

This error means you included the class Doctrine\Common\Annotations\Annotation\Target two times. It is difficult to say how you could achieve that.
Zend Framework 2 uses autoloading, so this type of error is typically impossible there. To install Doctrine, you use Composer dependency manager, and it creates all the autoloading configuration for you. But, if you then copy and paste the Composer-generated code in another project, you might have problem like yours.

The problem was from hosts file one site were to 127.0.0.1 and other to 192.168.10.20 i change and everything work normal

Related

How to write a vendor programme/module for ZFT

I would like to write a Zend Framework 2 vendor module, hosted on github, installable via composer and given to the world at large!
Now while I have no problems writing modules, where I am struggling is the mechanics around this.
My initial instinct would be to do something like this:
Set up a zend framework 2 skeleton app
Add my module as a normal module
Navigate to the module folder and create a git repo
Work on the module and update the module to my gitto...
Now logic tells me this is not the right way to go. So I am thinking, maybe I write the module as a stand alone outside of the skeleton app, push to the gito, and then pull from the gito to a working applicaiton...
If you can direct me to a tutorial, please let me know or if you can confirm or deny my proposed thinking that would be great too.
You probably need some app around your module to check if it works, however that shouldn't affect the way you create that module.
When it comes to Zend Framework 2 integrating modules, all you really need is a class that is called SomeNameSpace\Module which must be autoloadable via Composer. Note that there is NO requirement to place this file at a certain location. ZF2 will detect that you are using it with Composer and simply check with class_exists() instead of trying to locate a file, include it and then check for the class.
This class should reveal some configuration info about your module in the way ZF2 expects modules to do this, i.e. add bootstrap event listeners, return configuration data via getConfig() etc. It need not return anything for getAutoloaderConfig(), because that's what Composer is for.
To add the module to the ZF2 application you add the SomeNameSpace name to the file config/application.config.php:
return array(
'modules' => array(
'OtherStuffForTheDemoApp',
'SomeNameSpace' # this enables your module in your demo app
# and anywhere else where it's being used
),
ZF2 will see the module mentioned, try to instantiate SomeNameSpace\Module, ask it about all the configuration you defined, possibly calling the hook functions like onBootstrap() you provided there - and that's about it. Your module is responsible for doing the rest, i.e. provide a service manager configuration, provide controllers etc. All classes are autoloaded by Composer.
I believe the question of how to expose resources like images of a module hasn't been answered by Zend itself - at least I saw these questions being raised, but unanswered in the most current version of the documentation: http://framework.zend.com/manual/current/en/modules/zend.module-manager.intro.html
The organisation of files inside your module is completely up to you, although it seems common practice to place the source in a folder named src, tests probably go into tests.

Loading Angular.dart modules?

I'm confused about loading modules in Angular.dart ... (I hope).
So for angular.dart.ui let's say...I found myself putting in my main application under my main app module, type(Modal); ... but that wasn't enough apparently and I had to also add the import to the packages "timeout" and add type(Timeout); as well.
Do I need to keep adding type() all over the place and tracing back through someone else's code all the other dependencies they use??
Or should it just load all those when I inject, in this case, Modal?
I must be missing something here because adding the package you want and then testing in the browser and watching for "No provider" errors and adding all other dependencies one by one sounds like it slows down development, but I imagine the entire point of DI is to speed it up.
In you main you simply do
install(new ModalModule());
instead of
type(Modal) // old syntax
//...
bind(Modal) // new syntax
ModalModule is then installed as submodule which contains
TimeoutModule (which itself may contain some types)
ModalWindow and
Modal.
If you take a look at the source you will see that this way all you need is automatically registered for you.

Invalid IL code in System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider:.ctor (System.Type): method body is empty

I am deploying an MVC3 project to a Mono linux box. I had the skeleton working pretty nice, but when I started filling in some models, views, and controllers, I got the error you see above.
There does not seem to be much documentation on this; what little I've seen suggests that it cannot find my System.ComponentModel.DataAnnotations file, but I've set the dll to copy local and added it to the _bin_deployableAssemblies folder, with no success.
It seems like I'm missing something simple. Any guesses what it is?
It seems the problem goes away if I do NOT include the System.ComponentModel.DataAnnotations.dll file when publishing.

grails-doc creates copies of my classes in default package

In my grails 1.3.7 project, I have put all of my classes in com.mycompany.myapp, as you do. So this goes for services, controllers, domain classes. I have a filter that goes in its own package. My app works fine.
However, when I run grails doc, grails decides to create two pages for every class:
one in its right comp.mycompany.myapp package that has all the right Groovy Doc
the other takes all the above classes and pretends as if those also live in the default package.
So, target/docs contains two directories: 'DefaultPackage' and 'com', with DefaultPackage holding a copy of everything that lives under com/
Consequently, my groovy doc looks messy because there is two copies for each class.
How can I solve this?
It has been documented as a bug at GRAILS-6605. There is no workaround listed there for the bug.
I too faced the same issue and so created a plugin "Grails Runtime Docs" ( http://grails.org/plugin/grails-runtime-docs ) that solves this issue and generates both Java and groovy docs properly only 1 copy per class. It's grails aware and categorizes the classes into Controllers, Commands, Domains, Services and Tag Libraries. The groovy documentation is actually generated from runtime so as to include the dynamic methods also, adding "Dynamic Method Summary" & "Dynamic Method Detail" in the generated html docs, that provide their source information. Hope you find it useful.

Grails using a package to hold domain classes

Grails question: Confused about using a package to hold domain classes.
I'm using Netbeans on Mac to check out Grails.
When I create domain classes without using a package holding it, I can just go to localhost:8080/gTunes and the expected .gsp page is rendered properly.
However when I use a package (com.g2one.gtunes) to hold a domain class (Song), I don't see the .gsp page when I go to localhost:8080/gTunes. Instead I see a Directory view of folders/files such as META-INF, WEB-INF, etc. In order to see the expected .gsp page, I have to type in the specific URL localhost:8080/gTunes/index.gsp
In my research I've seen people talk about adding the following line but I can't figure out where to add it.
<%#page import="path.to.domains.*"%>
Any help is appreciated.
Thank you.
You need to add that import to the top of your GSP pages that use the domain class that you put in a package. Don't forget you'll also need an import in your controllers unless that are in the same package.
Add the specified line as the very first line in the GSP you are trying to render (show).
Figured out why I way I was having this issue. I'm going through Definitive Guide to Grails 2nd Edt on mac with NetBeans. I ran into this problem when I
created 'gtunes' project at /Users/name/NetBeans/gtunes
deleted 'gtunes' project and /Users/name/NetBeans/gtunes
created another project with same name at /Users/name/NetBeans/gtunes. I type in some code and run it and I run into the error I posted.
To get around this error,
I create 'gtunes' project located at /Users/name/NetBeans/gtunes
I right click on 'gtunes' project in NetBeans, issue 'Clean' command. Than I see some files are removed from ~/.grails/... in Output window
I right click on Album.groovy (possibly Song.groovy also) and issue 'Generate Views', NOT 'Generate All'
Run the project and it works!
Thanks all for comments and hopefully my mistake will help others avoid same mistake.

Resources