I realise that the stable release of Zend Framework 2 hasn't been been out for long, but having been through the skeleton tutorial it seems that there's a lot of work that needs to be done in order to get a new module working.
I'm just wondering if there are any tools available such as a CLI that make the creation of new modules/models etc easier.
Many thanks.
You can use the new ZFTool module to create new module and application structures for you via the cli
https://github.com/zendframework/ZFTool
Create a new module
zf.php create module <name> [<path>]
Create a new project
zf.php create project <path>
There probably will be tools to automate the creation of modules later on but probably not yet. Recall that the tools for autocreating projects for ZF1 didn't come out for quite a few releases. I'm not sure exactly which release but I think it wasn't until after 1.8 that the tools became available.
Until then, should DEFINITELY think about creating a 'skeleton' module and maybe putting it up on github or even create a pull request on the skeleton application to have your skeleton module, with the extra setup already done, added to the skeleton application or have it replace Zend's altogether.
A skeleton module already exists on github. It's been there for months and updated regularly as zf2 developed.
https://github.com/zendframework/ZendSkeletonModule
Related
I am working on a POC where I had to containerize a part of application for eg - I need to containerize "add to cart" functionality in an e-commerce website, I see a various example https://dzone.com/articles/docker-for-devs-containerizing-your-application to containerize whole application,but how to do for a part of it where my functionalities has dependency on other code parts as well.
Any pointers will be very helpful as I am totally stuck and don't see similar query anywhere else.
Thanks
IMHO, the first thing you need to do is read more about the concept of microservices and how it works.
Basically, the idea is decouple your monolithic application into as many services as your want and deploy it separate of each other. Each of this parts will comminicate with other parts by API calls.
There are a lot of benefits of using microservices architecture, and there is no the "better way" to do this, it will depends of how your application works and how your team is engaged.
I can recommend you a couple of link about microservices:
https://medium.com/hashmapinc/the-what-why-and-how-of-a-microservices-architecture-4179579423a9
https://opensource.com/resources/what-are-microservices
https://en.wikipedia.org/wiki/Microservices
If the application is not build as microservices, it wont actually work. The POC you should be striving for is to decouple it in another seperate application.... Which I guess its much harder and larger scope of the original POC
This is how I'd do it:
create a new java/gradle module called "addToCart"
extract all functionality related to "add to cart" functionality to this single gradle, spring boot module (add relevant dependencies to build.gradle and update settings.gradle to include the new module. And use compile("module") to have dependencies on existing modules brought into your new spring-boot module (note: you can't depend on a module that is a spring boot application - this will fail because spring-boot modules are compiled differently to lib modules without the spring boot plugin).
extract any dependencies this new module has on existing code out to another new library module that can be pulled in using a gradle dependency (you're aiming to end up with a Gradle multiproject build). This is required so that existing projects/modules as well as the new one can maintain the same dependencies.
use a gradle docker plugin like https://github.com/palantir/gradle-docker OR https://github.com/bmuschko/gradle-docker-plugin to create a docker image/container for you (instructions on website). You can do this part manually also.
If you're feeling particularly adventurous you could look into building GraalVM "native images" that are container friendly. Native images start incredibly fast. Because they start so fast you don't actually need to have them running all the time, which can lower your costs. There are trade-offs though. There's a talk from Devoxx Belgium 2019 that goes into details about it here: https://youtu.be/3eoAxphAUIg?t=978
I've being looking around for Zend\Tool which appears in version 1 but not in version 2. I did find another SO post where it was mentioned that they've not been added yet but that was over 6 months old.
Does anyone have an update on when they will be added or can point me in the direction of similar utilities?
ZFTool is now available for Zend Framework 2: https://github.com/zendframework/ZFTool
There's no such thing as Zend Tool at the moment. They are still working on it but when it will be released, no one can tell yet. However there are two great Git-Repositories out there, that pretty much cover crucial aspects of Zend Tool - creating a bare application and new modules
zendframework/ZendSkeletonApplication
zendframework/ZendSkeletonModule
Additionally someone posted a shell script to create a new skeleton module on my Blog, you can find the script right there. However i take no responsibility for that script, as i don't use it myself. ZF2 Modules are so simple and the SkeletonModule is all i need:
zf2crmod.sh
I am planning to build a project using zend framework 2.
But i find it very hard to setup zf2.
It is not easy to setup the framework and start working.
What i am looking is copy required zf2 files, put into the project and start working.
Like in cakephp where you need to make changes in database configurations and start working.
Can anybody help for this issue. this will be useful for many other developers also.
Thanks in advance for any help.
Have you tried the SkeletonApplication? It provides everything you need: Pre-setup bootstrapping, the directory structure, a basic application configuration.
Just clone it into your web directory and make sure that vendor/ZF2 gets cloned as well (--recursive flag).
This is currently the easiest approach to get started with a new ZF2 project.
If you need further assistance, please state your question more specificly.
// Edit: Although it makes sense to use composer or at least git to pull everything directly, you can just download the project (SekeletonApplication and ZF2) from Git. In my opinion, you shouldn't be too lazy here. Using composer etc. will save you a lot of time that you can spend on implementation.
Setting up ZF2 without the use of the command line is MUCH more of a pita than using it. Sure, you can download the SkeletonApplication and then you can Download ZF2 Core Library and put it into your include_path, but that's not too great.
I really suggest learning about the command line. I'm a windows user myself and hated it at first, but after getting around the first problems, i - now - find it really handy.
If you have trouble setting up your stuff or understanding it all, you may find my tutorial helpful which you can find right here: Zend Framework 2 Installation on Xampp for Windows
I had the same issue as you. I found the Skeleton application easy and quick to install, but I didn't need the translations that are included. As a result I created a stripped down, bare bones version which you are welcome to use.
You will find the ZendMinimumApplication on github.
We are currently looking at the newest version (2.60) of NopCommerce in MVC and we will be integrating it pretty soon…We’ve downloaded the Source Code and paid the 20$ for the User Guide documentation. The documentation is great! I mean…it is great in the sense that it explains how to deploy, install and how to work around the UI Frontend and Backend. This is great for an overall overview but what it lacks is the understanding of how to work with NopCommerce as a team. What are/is the best practices etc...
As an example (or parallel), if you decide to work with Dotnetnuke as a team, you usually work in the following fashion:
Each developer downloads/installs Dotnetnuke locally on their
machine.
You also download/install Dotnetnuke on a dedicated server (let’s say
dev-server).
As a developer, you work and create modules which you test locally
within your Dotnetnuke installation.
Once it is done, you package your module (and any SQL scripts that
comes with your module) into a zip file.
Once the package is ready, you upload/install that package on the
dedicated server (dev-server).
This approach works great for Dotnetnuke and more importantly if you have a team of developers creating modules.
My question is how does a team work with NopCommerce MVC?
I’m assuming it is a bad idea to directly work within the source code in case your team decides to modify core elements/source which will make any upgrade to newer versions impossible (or break changes).
I’m not sure if my parallel to Dotnetnuke is a correct one…but would anyone have any idea (or help me clarify) how does a team work with NopCommerce MVC.
In addition, should the team only rely on creating plugins for NopCommerce and stay away from modifying the core or should this be irrelevant?
What about adding new objects in SQL (or modifying existing ones) should we prefix our objects in case an eventual NopCommerce MVC upgrade creates similar objects and/or overwrites them?
Thank you for helping me shed some light on this.
Sincerely
Vince
Plugins in NopCommerce are almost like modules in DNN. Depending on what you need to do, it sometimes is necessary to modify the core code.
What I've been doing for the Services is create a new class and inherit from the existing service, then override the function you want to change. Create a new DependencyRegistrar class and set your new service classes as the implementation for that particular interface. Also make sure the Order property is 1 so that your DR class is loaded after the stock one. Since you're inheriting from the core class, any functions you didn't override will be handled by the parent class. If I need to add a new function, I'm just modifying the interface, putting a stub in the stock class, and implementing it in my own.
Views in the Nop.Web project can be overridden by Themes. The Admin stuff and the Web Controllers get trickier. I'm just modifying those files directly.
The Core and Data classes can be done using partial classes to add your new fields.
In any case you will still need to merge changes with your solution when an update is released. My opinion is that you are better off writing clean, readable code now and bite the merge bullet when it comes.
I don't really worry about SQL scripts right now because I'm a single developer but maybe you add a folder for ALTER scripts and name them after the day they were created. Then each dev knows which scripts they need to run when they get latest.
if so, where can it be found?
is it going to have a new handle as to not conflict with zf1's tool?
zf2 create module admin
Zend_Tool documentation can be found here:
http://framework.zend.com/manual/en/zend.tool.usage.cli.html
There is no Zend\Tool component implemented for Zend Framework yet. According to Matthew Weier O'Phinney (Project Lead Zend Framework):
Zend\Console is being worked on for beta4,
which lays the groundwork for new tooling; we may or may not have basic
tooling available for beta4 (depends on when Console hits the master
branch, basically).
Right now, the preferred method for starting with the application is to
use the ZendSkeletonApplication, along with ZendSkeletonModule, as these
give the basic infrastructure you need to start development of an
application and modules, respectively.
Source: http://zend-framework-community.634137.n4.nabble.com/Where-is-the-ZF-tool-in-ZF2-located-td4492524.html
The new Zend Tool for Zend Framework 2 has been released recently and could be found on github: https://github.com/zendframework/ZFTool