Coder Social home page Coder Social logo

Comments (10)

machour avatar machour commented on August 29, 2024 1

Mind you, I've came across another problem, as Schemas seems to be able to have multiple inheritance (as it's the case for LocalBusiness here):
https://schema.org/AutomotiveBusiness

I'm almost done with a new generator which make use of traits instead of inheritance, and it's coming together pretty well :)

/**
 * A particular physical business or branch of an organization. Examples of
 * LocalBusiness include a restaurant, a particular branch of a restaurant
 * chain, a branch of a bank, a medical practice, a club, a bowling alley,
 * etc.
 *
 * @see http://schema.org/LocalBusiness
 */
trait LocalBusiness
{
    /**
     * @see http://schema.org/Place
     */
    use Place;
    /**
     * @see http://schema.org/Organization
     */
    use Organization;

    /**
     * The price range of the business, for example $$$.
     *
     * @see http://schema.org/priceRange
     */
    public $priceRange;

I'll open a PR once done 🎉

from yii2-schema-org.

simialbi avatar simialbi commented on August 29, 2024

Hi @machour
Thanks for your input. You opened another issue #2. Is it completely broken a.tm. or are the models broken?
Your idea with generating models while composer install sounds great. I think this is the best way to solve it. Remove all of the models from repository and (re)generate them on composer install / update process.

from yii2-schema-org.

machour avatar machour commented on August 29, 2024

Actually I've uncovered some more issues with the library:

  • The model generation is broken, as the command is unable to fetch models pages from schema.org (#2)
  • When using php yii schema/schema-org 1 to clean models before generation, the Model.php file gets removed when it shouldn't be.

I've forked this repo and I'm currently fixing all these little things, while adding some caching to the console utility as I'm in really poor network conditions.

I'll let you know when I'm done for my needs, and then we'll discuss the changes and I'll open PRs for you to merge if you're okay with that :)

from yii2-schema-org.

simialbi avatar simialbi commented on August 29, 2024

Sounds good
Thank you for your contribution

from yii2-schema-org.

machour avatar machour commented on August 29, 2024

There you go, opened #4 which fixes a bunch of stuff.

To get back to this issue topic, I think I'd prefer having the ability to set a namespace & folder for the schema models to be generated in, and be able to track them in my repository.

It would be really bad if schema.org updated a schema and removed an attribute I'm using, without me being aware of that.

The command would look something like:

php yii schema/schema-org --namespace="\common\schemas" --path="common/schemas"

Furthermore, I'd add an extra optional parameters, allowing me to define the schemas I want to use in my app:

--schemas=Car,AboutPage

The console utility would generate models only for these schemas in this case (and their parents classes). In my case, this would allow me to have 20 generated classes instead of 571 :)

Autoloading performances & my IDE indexing would be grateful I guess :)

from yii2-schema-org.

simialbi avatar simialbi commented on August 29, 2024

Looks good. I'm going to check your changes in detail.
I understand your needs and the whish to be able to choose the models that should be generated and I think it's a good idea. But delivering an initial set of models is IMO still not necessary. Do you agree? Autogenerating on composer install could be a long time term, you're right. But may be it would be a good idea to define some of the most commonly used models (about 10 or 20) and autogenerate them? This would guarantee that the extension works without the need to do anything first without the delivery of about 500 models with the extension...

from yii2-schema-org.

machour avatar machour commented on August 29, 2024

I think that every developer will have its own need and will eventually have to generate the schemas he wants.

For example, I'm working on an automobile site and my needs are really specific.

IMHO we don't need any schema in the repository at all.

Reasoning:

We could ship just Thing as it's the root of all Schemas, but shipping any thing else would be a potential loss IMHO. And since as soon as I'd generate my schemas, Thing would be duplicated in my own folder, the base Thing will serve no purpose.

Also, if tomorrow Thing gets a new attribute in the specs, this library will instantly be considered as "bogus" before you re-run the generation and publish a new version.

from yii2-schema-org.

machour avatar machour commented on August 29, 2024

my last point made me think a bit more (sorry :D)

Schema.org have several releases: https://schema.org/docs/releases.html

If for some reason, a developer needs to stick to a particular version, let's say 3.3 (business requirement), he should be able to specify it in the CLI option.

The tool would parse this page instead https://schema.org/version/3.3/ which contains all information for 3.3 entities & attributes (sadly all anchors links point to the latest build page, so you have to copy anchors in the url bar to navigate correctly)

from yii2-schema-org.

machour avatar machour commented on August 29, 2024

Just came across https://schema.org/docs/developers.html#defs

This file contains all that's needed to generate the user-requested schemas. Using yii\helpers\ArrayHelper:index() would be a great way to parse the JSON object and greatly simplify the current CLI.

You can also change latest in the url to target a particular version ❤️

from yii2-schema-org.

simialbi avatar simialbi commented on August 29, 2024

Thank you for the link to that JSON. This will sure help to keep it simple. I will change the code based on this JSON.

from yii2-schema-org.

Related Issues (7)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.