Nowe posty

xx Dystrybucja pod HP Omen (6)
Wczoraj o 23:30:08
xx [Poradnik] Wyszukiwanie Sterowników (2)
Wczoraj o 21:08:23
lamp Problem z Linux Lite po instalacji (0)
Wczoraj o 19:50:30
xx Ile pingwinów? (1)
Wczoraj o 08:59:24
xx konfiguracja pale moon (0)
2024-03-24, 21:53:42
xx Plasma 6 w Neonie ssie trochę mniej ... (10)
2024-03-23, 02:38:11
xx problem z instalacja sterowników do karty sieciowej (3)
2024-03-18, 18:10:16
xx Plik abc.001 (1)
2024-03-17, 17:48:27
xx Zlecę dopracowanie programu w MatLab (0)
2024-03-13, 15:28:40
xx Linux Mint 21.3 XFCE brak dźwieku po paru minutach (karta muzyczna zintegrowana) (5)
2024-03-12, 23:07:01

Autor Wątek: Symfony - schema.yml (YAML)  (Przeczytany 8110 razy)

  • Gość
Symfony - schema.yml (YAML)
« dnia: 2010-02-20, 19:36:09 »
Próbuje utworzyć bazę w symphony z przykładu ale niestety nie udaje się mnie. Ktoś może zna się na symphony i mógłby objaśnić co nie tak. Uczę się, ze materiałów źródłowych ze strony, ale z niewielkim skutkiem.

Ok.

Mój schema.yml (kwestionowany przez parser)

        # config/doctrine/schema.yml

JobeetCategory:
            actAs: { Timestampable: ~ }
            columns:
              name: { type: string(255), notnull: true, unique: true }
JobeetJob:
            actAs: { Timestampable: ~ }
            columns:
              category_id:   { type: integer, notnull: true }
              type:          { type: string(255) }
              company:       { type: string(255), notnull: true }
              logo:          { type: string(255) }
              url:           { type: string(255) }
              position:      { type: string(255), notnull: true }
              location:      { type: string(255), notnull: true }
              description:   { type: string(4000), notnull: true }
              how_to_apply:  { type: string(4000), notnull: true }
              token:         { type: string(255), notnull: true, unique: true }
              is_public:     { type: boolean, notnull: true, default: 1 }
              is_activated:  { type: boolean, notnull: true, default: 0 }
              email:         { type: string(255), notnull: true }
              expires_at:    { type: timestamp, notnull: true }
            relations:
              JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id, foreignAlias: JobeetJobs }
       

JobeetAffiliate:
            actAs: { Timestampable: ~ }
            columns:
              url:        { type: string(255), notnull: true }
              email:      { type: string(255), notnull: true, unique: true }
              token:      { type: string(255), notnull: true }
              is_active: { type: boolean, notnull: true, default: 0 }
            relations:
              JobeetCategories:
                class: JobeetCategory
                refClass: JobeetCategoryAffiliate
                local: affiliate_id
                foreign: category_id


JobeetCategoryAffiliate:
  columns:
     category_id: { type: integer, primary: true  }
     affiliate_id: { type: integer, primary: true }
  relations:
     JobeetCategory: { onDelete: CASCADE, local:  category_id, foreign: id }
     JobeetAffiliate: { onDelete: CASCADE, local: affiliate_id, foreign: id
}
Oryginalny:

        # config/doctrine/schema.yml
Listing
  3-1
        JobeetCategory:
            actAs: { Timestampable: ~ }
            columns:
              name: { type: string(255), notnull: true, unique: true }
        JobeetJob:
            actAs: { Timestampable: ~ }
            columns:
              category_id: { type: integer, notnull: true }
              type:          { type: string(255) }
              company:       { type: string(255), notnull: true }
              logo:          { type: string(255) }
              url:           { type: string(255) }
              position:      { type: string(255), notnull: true }
              location:      { type: string(255), notnull: true }
              description: { type: string(4000), notnull: true }
              how_to_apply: { type: string(4000), notnull: true }
              token:         { type: string(255), notnull: true, unique: true }
              is_public:     { type: boolean, notnull: true, default: 1 }
              is_activated: { type: boolean, notnull: true, default: 0 }
              email:         { type: string(255), notnull: true }
              expires_at:    { type: timestamp, notnull: true }
            relations:
              JobeetCategory: { onDelete: CASCADE, local: category_id, foreign: id,
        foreignAlias: JobeetJobs }
        JobeetAffiliate:
            actAs: { Timestampable: ~ }
            columns:
              url:        { type: string(255), notnull: true }
              email:      { type: string(255), notnull: true, unique: true }
              token:      { type: string(255), notnull: true }
              is_active: { type: boolean, notnull: true, default: 0 }
            relations:
              JobeetCategories:
                class: JobeetCategory
                refClass: JobeetCategoryAffiliate
                local: affiliate_id
                foreign: category_id
             http://en.wikipedia.org/wiki/Object-relational_mapping
        17.
             http://propel.phpdb.org/
        18.
             http://www.doctrine-project.org/
        19.
                              -----------------            Brought to you by
Day 3: The Data Model                                                      35
        foreignAlias: JobeetAffiliates
JobeetCategoryAffiliate:
  columns:
     category_id: { type: integer, primary: true  }
     affiliate_id: { type: integer, primary: true }
  relations:
     JobeetCategory: { onDelete: CASCADE, local:  category_id, foreign: id }
     JobeetAffiliate: { onDelete: CASCADE, local: affiliate_id, foreign: id
}
Jest to kodzik z Practical symfony (ze strony symfony)

Byłbym wdzięczny za pomoc. Czytałem o YAML, ściągnełem manual'a jestem na str 18/85 ;-)

--edit ZipoKing--
zmiana tytułu wątku

ZipoKing

  • Gość
Symfony - schema.yml (YAML)
« Odpowiedź #1 dnia: 2010-02-20, 20:21:00 »
A jaki dokładnie błąd zwraca parser? Prawdopodobnie użyłeś gdzieś znaków tabulacji a YAML akceptuje tylko spacje (dokładniej wcięcie = 2 spacje).
BTW, Nie symphony tylko symfony

  • Gość
Symfony - schema.yml (YAML)
« Odpowiedź #2 dnia: 2010-02-20, 21:12:52 »
Fakt zapomniałem o najważniejszym ;-)

Błąd parsera:

Cytuj
tomasz@tomasz-laptop:/home/symphony/jobeet$ php symfony doctrine:build --model
>> doctrine  generating model classes

                                                                                                                                                                 
  Unable to parse file "/home/symphony/jobeet/config/doctrine/schema.yml": Malformed inline YAML string ({ onDelete: CASCADE, local: affiliate_id, foreign: id).

ZipoKing

  • Gość
Symfony - schema.yml (YAML)
« Odpowiedź #3 dnia: 2010-02-20, 21:23:32 »
U mnie poszło bez żadnych problemów, ale przez przypadek poprawiłem błąd, który u ciebie występuje: klamra zamykająca powinna być w tym samym wierszu co otwierająca, a u ciebie jest w następnym.

  • Gość
Symfony - schema.yml (YAML)
« Odpowiedź #4 dnia: 2010-02-20, 21:50:26 »
Hmmm... sorry, że tak często postuję... Ale nie mam pojęcia jak zedytować plik:

Cytuj
# # Populate this file with data to be loaded by your ORM's *:data-load task.
# # You can create multiple files in this directory (i.e. 010_users.yml,
# # 020_articles.yml, etc) which will be loaded in alphabetical order.
# #
# # See documentation for your ORM's *:data-load task for more information.
#
# User:
#   fabien:
#     username: fabien
#     password: changeme
#     name:     Fabien Potencier
#     email:    fabien.potencier@symfony-project.com
#   kris:
#     username: Kris.Wallsmith
#     password: changeme
#     name:     Kris Wallsmith
#     email:    kris.wallsmith@symfony-project.com

JobeetCategory:
          design:
            name: Design
          programming:
            name: Programming
          manager:
            name: Manager
          administrator:
            name: Administrator
        # data/fixtures/jobs.yml
JobeetJob:
          job_sensio_labs:
            JobeetCategory: programming
            type:          full-time
            company:       Sensio Labs
            logo:          sensio-labs.gif
            url:           http://www.sensiolabs.com/
            position:      Web Developer
            location:      Paris, France

          how_to_apply: |
             Send your resume to fabien.potencier [at] sensio.com
          is_public:       true
          is_activated: true
          token:           job_sensio_labs
          email:           job@example.com
          expires_at:      '2010-10-10'
          job_extreme_sensio:
JobeetCategory: design
          type:            part-time
          company:         Extreme Sensio
          logo:            extreme-sensio.gif
          url:             http://www.extreme-sensio.com/
          position:        Web Designer
          location:        Paris, France
          description: |
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
        eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
        enim ad minim veniam, quis nostrud exercitation ullamco laboris
        nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor
        in reprehenderit in.
        Voluptate velit esse cillum dolore eu fugiat nulla pariatur.
        Excepteur sint occaecat cupidatat non proident, sunt in culpa
        qui officia deserunt mollit anim id est laborum.
     how_to_apply: |
        Send your resume to fabien.potencier [at] sensio.com
     is_public:       true
     is_activated: true
     token:           job_extreme_sensio
     email:           job@example.com
     expires_at:      '2010-10-10'
Z tymi obostrzeniami z wcięciami YAML mało jest user-friendly ;-) Nawet mniej niż XML choć może być super-dobry ;-)

ZipoKing

  • Gość
Symfony - schema.yml (YAML)
« Odpowiedź #5 dnia: 2010-02-20, 23:10:14 »
http://www.symfony-project.org/jobeet/1_4/Doctrine/en/03 - Podejrzewam, iż przykład pochodzi dokładnie z tego rozdziału Jobeeta, gdzie ów kod jest przedstawiony i sformatowany w odpowiedni sposób.

  • Gość
Symfony - schema.yml (YAML)
« Odpowiedź #6 dnia: 2010-02-20, 23:16:11 »
Dzięki... Jeszcze nie czas testować moje umiejętności Yaml'a ;-)