Jump to content

[TOOLS] Oops, a framework for PrestaShop


mexique1

Recommended Posts

Hi community,

 

I'm excited to share with you a little framework that I came up with while developing modules.

It is called Oops (Object Oriented PrestaShop) and aims to become a tool to help developers build modules.

 

Right now it comes with following features :

 

- Built on Zend and Propel, allows out of the box usage of both framework

- Module framework : directory structure, convention over configuration, namespaces...

- PHP and/or Smarty templates

- Fully object oriented

- And more coming !

 

This is an early release, I would like to see if this works for anybody, and share ideas with you.

Oops is not ready for production use, and I'm still wondering about which license I should choose.

Anyway feel free to fork the repo and send me pull requests :)

 

 

Check the project on GitHub and tell me what you think : https://github.com/alexsegura/Oops

Link to comment
Share on other sites

I like the idea. It is what it should have been in the first place.

 

I am getting an exception with the example module in BO though (Smarty view displays OK):

 

Zend_View_Exception: script 'index/index.tpl' not found in path (U:/httpd/htdocs/ps1.4-dev/modules/hellooops/application/controllers/back-office/views\scripts/) in U:\httpd\htdocs\ps1.4-dev\tools\Zend\View\Abstract.php on line 980

 

And a question: how are you planning to get Zend and propel and Oops (nice name btw :/) to the target machine? package them with the module?

Link to comment
Share on other sites

Hum, the problem should be located in the Oops_Controller_Action_Helper_ViewResolver class.

Are you under Windows ? It seems that the class wrongly thinks there is an existing index.tpl file located there.

 

For the moment I think installing both Zend and Propel by themselves is sufficient.

They could be packaged with the module of course, Zend has a mechanism for that, but modules could be heavyweight then. I need you and the community to clarify this :)

 

EDIT : maybe it's better to report issues on GitHub, and keep this thread for general discussion ? https://github.com/alexsegura/Oops/issues

Link to comment
Share on other sites

For the moment I think installing both Zend and Propel by themselves is sufficient. They could be packaged with the module of course, Zend has a mechanism for that, but modules could be heavyweight then.

Yeah, I think they would. I had problems installing modules with zips over 1MB on some installs. In fact with 1.4.6.2 making a dummy module with some large images stuffed in a folder I cannot install it on my dev machine. Possibly a memory issue, did not track it down, i just slim the module down instead so packaging may a problem.

 

Adding instructions for manually adding those is an option but I don't like to make user work too hard to install a module. Ideally those libs would be added to default distribution of PS so a module builder knows for sure that they will be available.

 

I forgot to thank you for trying Oops !

:) As I forgot to thank you for the effort; there is a lot of work there. The more I look at it,the more I like it. Great potential for time savings and prevention of possible problems.

Link to comment
Share on other sites

As pointed out by another user, there is no AdminTab support in Oops !

 

To add tab support, I'm thinking about changing the directory layout to something like :

 

application
|-- mvc
|   |-- preferences
|   | |-- controllers
|   | | `-- IndexController.php => class MyModule_Preferences_IndexController
|   | `-- views
|   |-- foo-tab
|   | |-- controllers
|   | | `-- IndexController.php => class MyModule_FooTab_IndexController
|   | `-- views
|   |-- bar-tab
|   | |-- controllers
|   | | |-- IndexController.php => class MyModule_BarTab_IndexController
|   | | `-- OtherController.php => class MyModule_BarTab_OtherController
|   | `-- views
|   `-- hooks
|	   |-- controllers
|	   `-- views
`-- tabs 
   |-- Foo.php		 => class MyModule_Tab_Foo extends AdminTab
   `-- Bar.php		 => class MyModule_Tab_Foo extends AdminTab

 

So the back-office/front-office folders disappears, replaced by a more complex layout :

- the application/mvc/preferences folders will contain the MVC for the configuration part of the module

- the application/mvc/*-tab folders will contain the mvc part of any Tab, declared themselves in the application/tabs folder.

 

What do you think ? Is this sufficient ?

Link to comment
Share on other sites

Regarding the packaging, you are definitively right : the simpler = the better.

 

When you create a Zend_Application, there is an empty application/library folder created, which is intended to contain Zend, and other 3rd party libraries. Then, in the application.ini, you just need to reference this folder in a includePaths.library variable.

 

http://framework.zend.com/manual/en/zend.application.quick-start.html

 

Normally, this works out of the box for Oops. But this would still mean heavyweight modules, and this may cause duplicate classes.

 

On the other hand, if Oops helps developers make modules faster, maybe adding those dependencies is a small cost compared to development speed & confort.

 

Packaging is definitely an open discussion, and I'm waiting for your proposals.

Link to comment
Share on other sites

Hey, Oops is now packaged with its dependencies. Just a ZIP file to download and extract, and go :)

https://github.com/downloads/alexsegura/Oops/oops.alpha.zip

 

Why not give it a try now ? No need to have Git.

 

Also, a "small" fix : I forgot to commit the Oops/Db package !

Now it is available and there is also an example of usage in the README file on GitHub.

Link to comment
Share on other sites

I think it is way too early for that :)

Unfortunately, I haven't heard from the PrestaShop team about Oops... Seems you are the only "believer" so far.

I would be really pleased to know what they think !

 

Let's see how it goes, and maybe one day, Oops will be an official addon. But the road is long before that...

Let's wait for some community manager to see this thread :)

Link to comment
Share on other sites

I think it is way too early for that

Yeah, sure. For a decision, but I thought maybe before you started this effort you may have approached them and asked, e.g. "if I were to start work on a tool to make module builders' life easier would there be a chance that it is added to PS package". I am asking because it would be great shame after you, and others, spend time and effort on it if it turns out that it is not possible.

 

Seems you are the only "believer" so far.

Well, there is definitely potential but it needs momentum for general module development. Still, very useful for devs who also manage installations for clients who regularly demand new functionality/modules.

 

Let's wait for some community manager to see this thread

Or even better Fabien Serny :), may be worthwhile to ping him to let him know the existence of this thread.

Link to comment
Share on other sites

Community,

 

I'm looking to add easy AJAX support for modules in Oops.

 

AFAIK, it seems there is no clearly defined way of doing this in PrestaShop, am I wrong ?

 

What are the common patterns you use to expose content that can be retrieved via AJAX in your modules ?

Link to comment
Share on other sites

  • 2 weeks later...

Some news :

  • *.php extension support for templates (more secure, those files can't be read)
  • Theme templates override for modules (you can override a Smarty template with a PHP template, and vice-versa)
  • Hooks can be registered automatically via the config file

Link to comment
Share on other sites

  • 1 month later...

Hi Mexique,

 

This looks great, will you be following up and supporting 1.5 when its eventually released?

 

It's great to see tools like this to aid developers, as its something I feel is severely lacking in Prestashop and has been for some time in my opinion.

 

There's a lot of focus on merchants which is important, but it feels like developers are having to work with a hand tied behind their back quite often and hinders people trying to pick up Prestashop and help the community grow!

 

I'm following your repo on GitHub, and will give any feedback I can!

 

Mark

Link to comment
Share on other sites

Welcome Mark :)

 

I'm following closely PS 1.5 and there should be no problems using Oops as is. However, I haven't tested it yet.

 

I'm building a website that needs cart pricing rules so I will jump to PS 1.5 as soon as it is released, so yes, definitely, it will be supported.

However, there may be some API changes.

 

Glad to know there is another person interested :) Unfortunately, there have been very few adopters so far.

I think what Oops really needs is more examples, and free modules.

 

I'm currently more concentrated on building my actual website than the framework, but there are some modules that I have written with Oops that could be shared.

 

I haven't actualized the wiki, but there are some cool new features, like form elements to draw a category tree in 2-3 lines of code, layout support...

 

Definitely, feedback would be appreciated ;)

 

Thanks again for your message

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...