We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Module skeleton

Hi I am looking for some advice or tutorial how to create modules in PhalconPHP

something like this: https://www.yiiframework.com/doc/guide/1.1/en/basics.module

Could that be done via Phalcon and if yes where can I find the docs or tutorial.

Thanks.



13.6k

Could somebody also suggest some books on creating modules in general in PHP?



8.1k

Hi Module in PHP just is class Phalcon module sleleton is described in documentation very well. And are many example on Github Phalcon. You can also see my sleletonmulti on Github. https://github.com/oleg578/Phalconskeletonmulti I will be glad if this information will help you



13.6k

Thanks Oleg, but I need a separate directory for my module to store languages, config, views (both admin and frontend) so one file is not enough.

I need a similar structure to this:

modules/
   posts
       controllers
           admin.php
           posts.php
       language
           english
                posts.php 
           czech
                posts.php 
       models
           posts_model.php
       views
           admin/
                posts_add_post.php
                posts_edit_post.php
                posts_list_posts.php
           posts.php


13.6k

Hmm, I am looking at it right now and maybe it could be done like in your skeleton code. But your example is a little confusing. Because you have a module called "frontend". That's wrong approach, in my opinion, because when I develop a module I want to have in one location e.g. "forum" or "slider" the code for both admin area (backend) and for a frontend area. How to do that? In my example with "posts" (it's actually a working structure from CodeIgniter using HMVC) it's working like that. I have in a directory called modules all my parts of my website. How to do that in phalcon?



13.6k

Here is what I mean:

https://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter

I am interested in the last approach but not in CodeIgniter (I have already done that) but in Phalcon. I don't need a fancy CMS to install modules. I just want to be able to copy the module from one project to another in total commander and copy or create the table for that module in my db if its necessary and I am read to go ;). Could somebody please explain to me and probably others who are interested in this kind of approach to modules how to do that in Phalcon. I really like how it works in CodeIgniter using HMVC approach and copying modules from project to project is very easy. Thanks in advance.



8.1k

That's even better, we can do this very simply in Falcon. This the tree of my work project ( I can not fully show )

.
├── bundles
│   ├── agencia
│   │   ├── Agencia.php
│   │   ├── controllers
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   └── ___Controller.php
│   │   ├── models
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   └── ___s.php
│   │   └── views
│   │       ├── ___s
│   │       │   ├── ___.phtml
│   │       │   ├── ___.phtml
│   │       │   ├── ___.phtml
│   │       │   ├── ___.phtml
│   │       │   └── ___.phtml
│   │       ├── index.phtml
│   │       ├── layouts
│   │       │   └── main.phtml
│   │       └── main
│   │           ├── error404.phtml
│   │           ├── failroute.phtml
│   │           ├── index.phtml
│   │           ├── mainpage.phtml
│   │           ├── route404.phtml
│   │           └── test.phtml
│   ├── branch
│   │   ├── controllers
│   │   │   ├── ____Controller.php
│   │   │   ├── ____Controller.php
│   │   │   └── UserController.php
│   │   ├── Module.php
│   │   └── views
│   │       ├── actors
│   │       │   ├── all.phtml
│   │       │   ├── ___.phtml
│   │       │   ├── ___.phtml
│   │       │   ├── persona.phtml
│   │       │   └── ___.phtml
│   │       ├── fail
│   │       │   └── error404.phtml
│   │       ├── index.phtml
│   │       ├── layouts
│   │       │   ├── main.phtml
│   │       │   └── user.phtml
│   │       └── user
│   │           ├── goodbye.phtml
│   │           └── signin.phtml
│   ├── dashboard
│   │   ├── controllers
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── ___Controller.php
│   │   │   ├── __Controller.php
│   │   │   ├── UserController.php
│   │   │   └── ___Controller.php
│   │   ├── Dashboard.php
│   │   ├── models
│   │   │   ├── ____s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ____s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ___s.php
│   │   │   ├── ____s.php
│   │   │   └── ____s.php
│   │   └── views
│   │       ├── ____s
│   │       │   ├── edit.phtml
│   │       │   ├── index.phtml
│   │       │   └── new.phtml
│   │       ├── ____e
│   │       │   ├── attachimage.phtml
│   │       │   ├── edit.phtml
│   │       │   ├── index.phtml
│   │       │   └── new.phtml
│   │       ├── index.phtml
│   │       ├── layouts
│   │       │   └── article.phtml
│   │       ├── main
│   │       │   ├── error404.phtml
│   │       │   └── index.phtml.save
│   │       ├── ____
│   │       │   └── edit.phtml
│   │       ├── ____
│   │       │   ├── index.phtml
│   │       │   └── setmain.phtml
│   │       ├── ____
│   │       │   └── edit.phtml
│   │       ├── _____
│   │       │   └── edit.phtml
│   │       ├── ___
│   │       │   └── edit.phtml
│   │       ├── user
│   │       │   └── edit.phtml
│   │       └── ____
│   │           └── index.phtml
│   └── library
│       ├── Aux.php
│       ├── I18n.php
│       └── Image.php
├── config
│   ├── config.php
│   └── i18n
│       ├── de.php
│       ├── en.php
│       ├── fr.php
│       ├── pl.php
│       └── ru.php
├── public
│   ├── 50x.html
│   ├── assets
│   │   ├── artimage
│   │   │   ├── thumb
│   │   │   └── web
│   │   ├── css
│   │   │   ├── awesome
│   │   │   │   ├── css
│   │   │   │   └── font
│   │   │   ├── dashstyle.css
│   │   │   ├── normalize.css
│   │   │   ├── normalize.min.css
│   │   │   └── style.css
│   │   ├── fonts
│   │   ├── img
│   │   │   ├── icons
│   │   ├── js
│   │   │   ├── dropzone
│   │   │   │   ├── css
│   │   │   │   ├── dropzone.js
│   │   │   │   └── images
│   │   │   ├── jquery-2.0.3.min.js
│   │   │   ├── production
│   │   │   │   ├── ca11a1b000bb2b15c26.js
│   │   │   │   └── final.js
│   │   │   ├── scripts.js
│   │   │   ├── tinymce
│   │   │   └── video-js
│   │   ├── photo
│   │   │   ├── thumb
│   │   │   └── web
│   │   └── video
│   │       ├── thumb
│   ├── favicon.ico
│   └── index.php
├── stamps
│   └── wm.png

73 directories, 525 files

As you can see, everything is solved very simply Basis on my https://github.com/oleg578/Phalconskeletonmulti

P.S. Unfortunately, CI is already very outdated and can not optimally solve many tasks. To better understand what are the modules in Phalcon, look at the definition of bundles in Symfony2



13.6k

Thanks a lot Oleg, I will check it, it seems that it can be done with Phalcon too. I just need to study it more.



31.3k

Hi Oleg, how do you manage to you tinymce ? Do you use the plugins MoxieManager ?



8.1k

I used tinymce with standard install via MCE documantation. Without MoxieManager