joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.75k stars 3.64k forks source link

Joomla ORM with Elixir Ecto language ORM #20941

Closed shahryarjb closed 6 years ago

shahryarjb commented 6 years ago

I want to try to create Json restful, but I have a problem with Joomla ORM, for example in elixir language in Ecto ORM , we can write types

schema "cms_post" do
  field :title, :string, null: false
  field :status, :boolean, null: false
  field :post_type, :string, null: false
  field :download_ext_link, :string, null: false
  field :price, :string, default: "0", null: false
  field :pic_x1_link, :string, null: false
end

@all_fields ~w(title status post_type download_ext_link price pic_x1_link pic_x2_link pic_x3_link group_acl description changelog changelog_category plugin plugin_category discourse discourse_link screen_shot screen_shot_category learn learn_category seo_tag seo_alias_link seo_words seo_description seo_language seo_language_link cms_post_category_id)a

def changeset(struct, params \\ %{}) do
    struct
    |> cast(params, @all_fields)
    |> validate_required(@all_fields)
    |> unique_constraint(:seo_alias_link, name: :index_of_post_alias_unique_link, message: "alias link already exists.")
    |> validate_inclusion(:seo_language, ["en", "fa"])
    |> validate_inclusion(:group_acl, ["admin", "actived", "unactived", "blocked"])
    |> validate_inclusion(:post_type, ["article", "shop", "free"])
    |> validate_length(:title, min: 3, max: 100)
    |> validate_length(:description, min: 100)
    |> validate_length(:seo_words, min: 3, max: 100)
    |> validate_length(:seo_description, min: 50, max: 264)
    |> foreign_key_constraint(:cms_post_category_id)
    |> validate_field_relational(:cms_post_category_id)
end

if you see that code in elixir Ecto , you will know, all error of user request are processed by ORM and Json web service router can handle it , but in Joomla I don't have any option for creating handle web service well, therefore it takes me for long time to create web service in Joomla.

it is clear that Elixir is a modern language , but Ecto just is a library which is created by elixir community.

Joomla developers can't create big work until Joomla will want to do these. Joomla is a framework laravel too or Phoenix.

Thank you.

https://hexdocs.pm/ecto/Ecto.html

Fedik commented 6 years ago

just a question, how it related to Joomla? it even not PHP

I want to try to create Json restful

for this you need to create a component in Joomla, If I right understood your question.

shahryarjb commented 6 years ago

Hello @Fedik , you think all of these are for the sake of Elixir Language ? Im not sure , because Php have many power too.

for this you need to create a component in Joomla, If I right understood your question.

Yes, I need to create multi component and integration Joomla to mobile app or react app and ... , but I have no more option in Joomla for these. for this purpose :

it takes me for long time to create web service in Joomla.

I have to write more code and I need more time to create one web service .

by the way in laravel the developer have a magic tools for creating MVC , this tools may be for create new component in Joomla

I think the Joomla which is one of the best cms of the world should do different option in the its cms for developers, in the all of version which were released , Joomla tries to say that it is just a cms not a framework .

Thanks , I hope Joomla always is good. Especially that the Joomla4 is coming soon.

Please see : https://laravel.com/docs/5.6/eloquent

Capsule::schema()->create('todos', function ($table) {

       $table->increments('id');

       $table->string('todo');

       $table->string('description');

       $table->string('category');

       $table->integer('user_id')->unsigned();

       $table->timestamps();

       $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');

   });
wilsonge commented 6 years ago

We're working on our own ORM in J4 - WIP at https://github.com/joomla-projects/entities

Given this post is largely just advertising other frameworks I'm going to close this. If you want to bring up specific issues about the orm - please do so in the entity repo

shahryarjb commented 6 years ago

@wilsonge now a days, we advertise when the system needs a better way . interesting !!!!

wilsonge commented 6 years ago

I've given you a link to our WIP at doing this better - so of course that means we are working on a better way and that we accept the current system needs improving.