Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [SF2][SF]Moduły: Tree,Translatable, Sluggable, Timestable, Loggable
Forum PHP.pl > Forum > PHP > Frameworki
basso
Witam,
Zabrałem się za używanie: Tree,Translatable, Sluggable, Timestable, Loggable .
Z tego co wyczytałem, to do tego potrzeba jest zainstalowania Stof DoctrineExtensionsBundle.
Próbowałem zainstalować stąd: https://github.com/stof/StofDoctrineExtensi...s/doc/index.rst , ale nie bardzo mi to wychodzi.

Nie wiem czy dobrym torem idę. Wszystko robię na Symfony 2.1.

Stanąłem na i sypie błędami jak dopisuje to do configa "Add the extensions to your mapping" :
# app/config/config.yml
doctrine:
orm: ......

Podłączał ktoś z Was to?
pedro84
Jakimi błędami?
basso
Hej... system stawiałem i z deka mi zeszło, więc tak z opóźnieniem smile.gif

Nie wiem, czy ta wersja z której próbowałem instalować, jest do 2.1. Patrząc iż jest to wpisane w composer.json to rozumiem, że nie jest to 2.0 smile.gif

Wiec tak.
1. Zaciągnęło mi dobrze całego bundla po zainstalowaniu
2. Kolejny krok to zgodnie z instrukcją: Register the DoctrineExtensions and Stof namespaces

gdy wklejam to:
  1. // app/autoload.php
  2. $loader->registerNamespaces(array(
  3. 'Stof' => __DIR__.'/../vendor/bundles',
  4. 'Gedmo' => __DIR__.'/../vendor/gedmo-doctrine-extensions/lib',
  5. // your other namespaces
  6. ));


To mi wyskakuje:
Fatal error: Call to undefined method Composer\Autoload\ClassLoader::registerNamespaces() in C:\wamp\www\sym2\app\autoload.php on line 14

Moja struktura app/autoload.php wygląda tak: (tutaj wersja bez wklejonego powyższego kodu).

  1. <?php
  2.  
  3. use Doctrine\Common\Annotations\AnnotationRegistry;
  4.  
  5. $loader = require __DIR__.'/../vendor/autoload.php';
  6.  
  7. // intl
  8. if (!function_exists('intl_get_error_code')) {
  9. require_once __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php';
  10.  
  11. $loader->add('', __DIR__.'/../vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs');
  12. }
  13.  
  14. AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
  15.  
  16. return $loader;



Kolejnych kroków nie mogę wykonać...no bo najpierw muszę to do autoloadera załadować ale jak widać jest jakiś problem ;/
pedro84
Nie czytasz dokumentacji dobrze, mieszasz instalację za pomocą composera i bez:
Cytat
Register the DoctrineExtensions and Stof namespaces

Only required, when using submodules.


Dobra, na szybko instalacja przeszła, kroki:

# composer.json
Kod
"require": {
    "stof/doctrine-extensions-bundle": "dev-master",
}

potem w konsoli wykonujesz:
Kod
composer update
# ewentualnie
php composer.phar update


potem w pliku AppKernel.php:
  1. // app/AppKernel.php
  2. public function registerBundles()
  3. {
  4. return array(
  5. // ...
  6. new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
  7. // ...
  8. );
  9. }


i dalej już konfiguracja w pliku config.yml.
basso
WItam,
no ... masz rację, okej mam to tak zrobione.

Teraz wrzucam w # app/config/config.yml Add the extensions to your mapping


Zamiast:
  1. # Doctrine Configuration
  2. #doctrine:
  3. # dbal:
  4. # driver: "%database_driver%"
  5. # host: "%database_host%"
  6. # port: "%database_port%"
  7. # dbname: "%database_name%"
  8. # user: "%database_user%"
  9. # password: "%database_password%"
  10. # charset: UTF8
  11. #
  12. # orm:
  13. # auto_generate_proxy_classes: "%kernel.debug%"
  14. # auto_mapping: true



Daję

  1. # app/config/config.yml
  2. doctrine:
  3. orm:
  4. entity_managers:
  5. default:
  6. mappings:
  7. gedmo_translatable:
  8. type: annotation
  9. prefix: Gedmo\Translatable\Entity
  10. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
  11. alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
  12. is_bundle: false
  13. gedmo_translator:
  14. type: annotation
  15. prefix: Gedmo\Translator\Entity
  16. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
  17. alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
  18. is_bundle: false
  19. gedmo_loggable:
  20. type: annotation
  21. prefix: Gedmo\Loggable\Entity
  22. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
  23. alias: GedmoLoggable # this one is optional and will default to the name set for the mapping
  24. is_bundle: false
  25. gedmo_tree:
  26. type: annotation
  27. prefix: Gedmo\Tree\Entity
  28. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
  29. alias: GedmoTree # this one is optional and will default to the name set for the mapping
  30. is_bundle: false




i wyskakuje:

  1. Whoops, looks like something went wrong.
  2.  
  3. 1/1ServiceNotFoundException: The service "cache_warmer" has a dependency on a non-existent service "doctrine".
  4. in C:\wamp\www\sym2\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\
    Compiler\CheckExceptionOnInvalidReferenceBehaviorPass.php line 59
  5. at CheckExceptionOnInvalidReferenceBehaviorPass->processReferences(array(object(Reference))) in C:\wamp\www\sym2\vendor\symfony\symfony\src\Symfony\Component\DependencyInjection\
    Compiler\CheckExceptionOnInvalidReferenceBehaviorPass.php line 43



Kurcze ni teraz nie wiem czy to miało być zamiast tamtego czy dodatkowo. Ale i tak i tak próbuje i ten sam błąd.
pedro84
Wrzuć na pastebin swoją konfigurację, bo coś masz namieszane: AppKernel.php i config.yml. Jak mniemam Composer aktualizuje Ci paczki?
basso
ooo dzięki,

Tutaj poniżej to czego potrzebujesz.

APP KERNEL => http://pastebin.com/CRGTG9ws
config.yml => http://pastebin.com/MfccS4gS
pedro84
Odkomentuj konfigurację doctrine.dbal (na podstawie Twojego kodu: http://pastebin.com/2p6u6te7). Potem z konsoli:
Kod
php app/console cache:clear
i powinno śmigać.
basso
Dzięki wielkie za poświęcony czas. Jest coraz lepiej... kurcze tak myślałem że ta tablica orm jest jedna...

Teraz wyskakuje MI :
Unknown Entity namespace alias 'BackendPagesBundle'.
500 Internal Server Error - ORMException


Czy przez zainstalowanie tego GEDMO muszę wszystko mieć na adnotacjach? Bo ja cały routing mam na .yml i takbym chciał mieć => jeśli się da.
pedro84
Skądże. Zajrzyj do tego linka, powinien wiele wyjaśnić: http://stackoverflow.com/a/12616261/669422
basso
Hej,
Z tego co mi podesłałeś to rozumiem, że w mapowaniu musi być cała ścieżka do Bundli.

Zatem miałem tak:

  1. orm:
  2. entity_managers:
  3. default:
  4. mappings:
  5. gedmo_translatable:
  6. type: annotation
  7. prefix: Gedmo\Translatable\Entity
  8. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
  9. alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
  10. is_bundle: false
  11. gedmo_translator:
  12. type: annotation
  13. prefix: Gedmo\Translator\Entity
  14. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
  15. alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
  16. is_bundle: false
  17. gedmo_loggable:
  18. type: annotation
  19. prefix: Gedmo\Loggable\Entity
  20. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
  21. alias: GedmoLoggable # this one is optional and will default to the name set for the mapping
  22. is_bundle: false
  23. gedmo_tree:
  24. type: annotation
  25. prefix: Gedmo\Tree\Entity
  26. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
  27. alias: GedmoTree # this one is optional and will default to the name set for the mapping
  28. is_bundle: false
  29.  


Teraz mam tak


  1. BackendPagesBundle:
  2. type: annotation
  3. prefix: Gedmo\Translatable\Entity
  4. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
  5. alias: GedmoTranslatable # this one is optional and will default to the name set for the mapping
  6. is_bundle: false
  7. BackendPagesBundle:
  8. type: annotation
  9. prefix: Gedmo\Translator\Entity
  10. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translator/Entity"
  11. alias: GedmoTranslator # this one is optional and will default to the name set for the mapping
  12. is_bundle: false
  13. BackendPagesBundle:
  14. type: annotation
  15. prefix: Gedmo\Loggable\Entity
  16. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Loggable/Entity"
  17. alias: GedmoLoggable # this one is optional and will default to the name set for the mapping
  18. is_bundle: false
  19. BackendPagesBundle:
  20. type: annotation
  21. prefix: Gedmo\Tree\Entity
  22. dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Entity"
  23. alias: GedmoTree # this one is optional and will default to the name set for the mapping
  24. is_bundle: false
  25.  



I dalej to samo po wyczyszczeniu Cache. Mowa coś tam jest jeszcze o Shouldn't it be enough with auto_mapping: true? Tylko gdzie to wpisać?
Co jeśli mam więcej bundli , a mam .

Proszę o pomoc i z góry dziękuję.
pedro84
Hej,

zobacz te zagadnienia na Githubie:
https://github.com/stof/StofDoctrineExtensi...ndle/issues/141
https://github.com/stof/StofDoctrineExtensi...ndle/issues/134
https://github.com/stof/StofDoctrineExtensi...to-your-mapping

Postawiłem teraz aplikację na SF, taki zapis działa dobrze:
Kod
# Doctrine Configuration
doctrine:
    dbal:
        driver:   "%database_driver%"
        host:     "%database_host%"
        port:     "%database_port%"
        dbname:   "%database_name%"
        user:     "%database_user%"
        password: "%database_password%"
        charset:  UTF8
    orm:
        auto_generate_proxy_classes: "%kernel.debug%"
        auto_mapping: true
        mappings:
            StofDoctrineExtensionsBundle: ~
basso
Działa mi sluggable, uaktywniłem jeszcze w config.yml



stof_doctrine_extensions:
default_locale: en_US
orm:
default:
sluggable: true


I śmiga.

Dzięki WIELKIE ZA POMOC exclamation.gif!
phpion
@basso:
Na przyszłość proszę rozważniej przyznawać "Pomógł". Nie sądzę by:
Cytat
Jakimi błędami?

było dla Ciebie faktycznie pomocne...
basso
A no chyba przegiąłem. Po prostu wklikiwałem smile.gif

Pytanie mam jeszcze jedno jak ktoś może pomóc. Próbowałem w kolejnych projektach instalować sluggable, ale wszędzie ten sam błąd.
To się pojawia przy zaciąganiu jak wpisuję: composer upadte, ciągnie ciągnie i przy końcu jak natrafia właśnie na kirshwall... to się wywala.



INSTALACJA STOF-A bez COMPOSERA.

Założyłem sobie nowy projekt.
1. Przeniosłem Stof z Vendorw do nowego projektu
2. Dodałem wpis w config i Kernel

I nie bardzo chce działać ten Stof. Oczywiście jak zapuszczę composerem to działa, tylko ja nie zawsze mam internet.

Pytanie:
1. Czy wie ktoś jak można zainstalować Stofa bez composer, gdzie jakie wpisy trzeba dać oprócz tych których dodałem ?[size="6"][/size][color="#FF0000"][/color]
semafor1985
u mnie też wywalalo ten blad
zaaktualizowalem Symfony do najnowszej wersji
tam już chyba ten komponent nazywa się inaczej, jest w innym miejscu lub wogole go nie ma
i blad nie wsykakuje
basso
Mówisz o Symfony 2.2 ? Dużo się różni od 2.1, bo nie wiem czy stofa mi się uda zainstalować ;/

Jak usunać katalogi .git z poziomu windowsa z zaciągniętych vendorów?


Faktycznie, w wersji 2.2 problem nie występuje. Zatem przerzucam się na wersję 2.2 smile.gif
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.