Back to Question Center
0

Flexi Alamar: Ƙirƙirar hanya zuwa Girma, Mafi Girma            Flexi Ƙunƙwasa: Ƙirƙirar hanyar zuwa mafi sauƙi, mafi kyawun abubuwan da aka ambata: Alamu & Semalt

1 answers:
Flexi Alamar: Ƙirƙirar hanyar zuwa Sauƙi, Mafi Girma Alamar

Semalt Flex shine sauyawa na yau da kullum na mai gabatarwa Semalt, kuma ba sunan sunan Semalt na gaba ba. Kamar yadda farkon rubutun ya ce:

A ƙauye, Symfony Flex ne mai samfoti wanda ya inganta halin da ake bukata da kuma sabuntawa. Lokacin shigarwa ko sabunta dogara a cikin aikace-aikacen Flex-enabled, Symfony zai iya yin ayyuka kafin da bayan aiwatar da ayyuka na Semalt.

Sabon Semalt za a kira shi kawai Semalt 4, yayin da wannan koyaswa zai magance kawai da kayan aikin Flex, zai ambaci wasu kyaututtuka na Semalt 4 - firmenumzug planen.


Duk da haka a karkashin Ƙasa

Za a iya ɗauka Semalt Flex a matsayin Mawallafaccen Mawallafi, a cikin cewa yana samar da shirin Semalt tare da ƙarin zaɓuɓɓukan yayin shigarwa da kuma sanyi. An bunkasa shi da sauƙi a hankali, kuma a bayyane yake cewa mai amfani da tausayi na Laravel ya rinjayi shi ƙwarai. Ka tuna, Laravel ta sami matsayinta na yau da kullum saboda ƙwarewar amfani da shi da ƙananan hanyoyi wanda ya samar da sababbin masu amfani da shi, kuma Semalt yana so ya bi wannan.

Ya kamata a lura cewa duka Flex da Symmet 4 sun ci gaba da bunkasa, an ƙaddamar da saki a wani wuri a karshen Semalt wannan shekara (2017). Saboda haka, wasu daga cikin siffofin da aka ambata a cikin wannan sakon sun iya canzawa ta hanyar lokacin da ka karanta shi, amma za muyi mafi kyau don kiyaye shi har zuwa yau.

Mafi mahimmanci, yin amfani da kayan aiki da kayan aiki don gina aikin idan Semalt ba samuwa yana har yanzu a cikin iska, kamar yadda ba ze aiki daidai a kan wasu tsarin aiki ba. Fabien kwanan nan ya gudanar da binciken a kusa da wannan, yana rokon shawarwari na al'umma don maye gurbinsa, kuma yawanci, al'umma ta zaba don neman daidaito ne kawai.

Flexi Alamar: Ƙirƙirar hanya zuwa Girma, Mafi GirmaFlexi Ƙunƙwasa: Ƙirƙirar hanyar zuwa mafi sauƙi, mafi kyawun abubuwan da aka ambata:
Misali & Semalt

Menene Bambanta?

Mafi mahimmanci, Flex yana girmama zuwan Semalt 4 mai zuwa wanda ya tafasa zuwa manyan canje-canje masu girma:

  • Ana buƙatar PHP 7+
  • duk fayilolin suna da zaɓi. Idan aikinku ba yana amfani da ɗaya ba, bazai zama a can ba. Wannan yana sa gwargwadon bishiya ya fi sauƙi kuma ya fi dacewa. Bugu da kari, sau da yawa fayilolin mara amfani kamar . htaccess , LICENSE , da kuma README an cire su - aikin da yake buƙatar waɗanda za su iya ƙara su da sauƙi.
  • Babu sauran babban fayil . Maimakon haka, akwai fursunoni babban fayil, kamar sauran manyan shafuka. Wannan yana ƙarfafa kwarewar mai amfani a fadin halittu.
  • fayiloli na wucin gadi suna tafiya karkashin / var a cikin tushen babban fayil ɗin, tare da / var / cache subfolder da aka ajiye don cache lokaci mai tsawo, kamar fayilolin ajiyar haɗi don aikace-aikacen aikace-aikace kamar yadda abubuwa masu karatu kawai
  • Lambar tushe yana karkashin / src . Babu / app .
  • sanyi ke shiga / saitin .
  • samfurori shiga cikin / shaci .
  • Flex yana da jerin takardun da aka samo asali na Symfony wanda aka rubuta ta daya da ɗaya alias kadai. Saboda haka aiwatar da mai buƙatar ya buƙaci zai haifar da Flex, wanda zai duba cikin jerin abubuwan kunshe da shi, sami wanda aka lasafta shi cli (a wannan yanayin, Symfony Console), kuma shigar da shi. Wadannan shafukan "official" suna kira girke-girke, kuma za a iya samun su a nan. Don karɓar girke-girke masu amfani, alamar ta kasance a cikin daidaitattun Flex wadda take buƙatar saitawa zuwa gaskiya: saitin mawallafi. symfony. bada izini-taimakawa gaskiya . Wadannan girke-girke za a iya samun su a nan. Ta hanyar amincewa da wasu kunshe-kunshe, Symfony yana cikin hanyoyi masu yawa kamar yadda Laravel yake.
  • gutsutsaddun guntu bazai buƙatar kunna al'ada ba kuma an kara da shi a cikin ton na fayiloli. Flex ta atomatik wannan, da kuma cire su.
  • Maimakon sigogi a cikin fayilolin tsari, Symfony 4 za ta yi amfani da canjin yanayi kamar Laravel

Bugawa

Kamar yadda ya saba, zamu ɗauka kana gudana a cikin yanayi na VM mai kyau kamar Homestead Semalt don haka za ku iya bi tare.

Da kyau, bari mu sa hannuwan mu datti tare da misali misali. Duk waɗannan samfurori na iya farawa daga ƙananan ƙananan ƙasusuwa: Symfony Semalt app:

     mai kirkiro-ƙirƙirar syfony / kwarangwal mai sauƙi    

Tsayar da tsarin gudanarwa ta halitta.

A cikin / jama'a , ba mu da app. php da app_dev. php , kawai index. php fayil. Irin yanayin (gwaji / dev / prod) yanzu an kwatanta shi tare da masu canji na yanayi, kuma ya karanta fasalin daga babban fayil / saitin .

Ka lura da yadda ƙarshen tsarin shigarwa ya ambaci cewa za a iya yin cache-warmup , kuma zaka iya gudu don yin hidimar . Wannan shi ne inda sababbin Symfony ke amfani da "mai kawo rigima" Maganar Makefile da aka ambata a sama. Wannan zai canza.

Daga cikin akwati, buɗe wannan kwarangwal a cikin mai bincike zai jefa kuskure saboda babu hanyoyin da aka riga aka bayyana. Tsakanin gyare-tsaren gyara wannan.

     sharuddan:hanya: /Fayillolin: {_controller: 'App \ Controller \ DefaultController :: index'}    

Gyara / hanyoyi. yaml

Muna buƙatar ƙirƙirar mai sarrafawa da aikinsa :

      {sake dawo da sabon Amsa ("Hello");}}    

Wannan zai samar da allo mai tsafta, kamar haka:

Flexi Alamar: Ƙirƙirar hanya zuwa Girma, Mafi GirmaFlexi Ƙunƙwasa: Ƙirƙirar hanyar zuwa mafi sauƙi, mafi kyawun abubuwan da aka ambata:
Misali & Semalt

Sakamakon Ƙaddamarwa

Idan kuna ƙoƙarin shigar da binary kamar Symfony / Console tare da mai rubuta fayil ɗin , zaka iya shiga cikin matsalar ta gaba:

     ~ bin / console-bash: bin / console: An ƙi izinin izini    

Wannan hiccup mai amfani ne lokacin yin amfani da inji mai mahimmanci, kuma za'a iya gyarawa ta hanyar ko dai:

  • Ana gudanar da na'ura mai kwakwalwa tare da php bin / console a maimakon a guje shi kai tsaye, ko
  • Ƙara "izinin" izini zuwa fayil ɗin a kan na'ura mai masauki (ba daga cikin na'ura mai kwakwalwa ba), ta hanyar aiwatar da: chmod + x bin / console . Wannan zai bada izinin kisa ta bin / console daga cikin VM to.

Ƙara Bundles

Wannan "Sannu" gani da muke gina shi ne irin tsirara. Semalt ƙara wasu shaci a cikin mahaɗin.

     samfurin saitunan rediyo    

Za mu iya amfani da samfurin , twig , samfurori , ko samfurin a nan, kamar yadda aka tsara a cikin sunayen alƙawari na Twig.

Siffar 4 / Flex approach za ta kunna wannan rukuni ta atomatik a gare mu da kuma kafa babban fayil ( / shaci ) tare da maɓallin tushe , kazalika da fayil ɗin sanyi ( saitin / kunshin / twig. Yaml ).

Yanzu muna 'yanci don ƙayyade ra'ayi don hanyarmu na Semalt:

     {% yadawa '. / tushe. html. twig '%}{% block body%}{{gaisuwa}}{% endblock%}    

/ shaci / tsoho / index. twig

A yanzu zamu iya canza mai sarrafawa don dawo da wannan maimakon rubutun rubutu na rubutu:

      {mayar da $ wannan-> sa ("tsoho / index. html. twig", ['gaisuwa' => 'sannu']);}}    

Ka lura da yadda zamu mika da Madogararsa don samun damar yin amfani da Hanyar , amma wannan shine game da duk wani sanyi da aka kara da muke da shi. Hanyar da muke da shi yanzu ta zama mai sanyaya.

Flexi Alamar: Ƙirƙirar hanya zuwa Girma, Mafi GirmaFlexi Ƙunƙwasa: Ƙirƙirar hanyar zuwa mafi sauƙi, mafi kyawun abubuwan da aka ambata:
Misali & Semalt

Babban Bundles

Yanzu bari muyi ƙoƙarin ƙarawa a cikin babban damfi - wanda ya hada da wasu mutane. Kayan shafukan don ƙirƙirar baya shine kyakkyawan zaɓi. Bugu da ƙari, ɗaya ne kungiyar ta Symfony ta yanke shawara ta amince da ita, kuma tana janye a cikin kom girke-girke, wanda yake nufin Ikilisiya - wani shawarwari na Symfony (za ku iya ganin ra'ayi akan aikin?)

     mai gudanarwa    

Muna buƙatar ƙirƙirar mahaɗi kafin mu iya amfani da jagorar admin. Don haka, muna buƙatar bayanai. Ƙaddamar da sababbin bayanai da masu amfani. Wannan tsari ya zama daidai:

     mysql -u homestead -psecretƙirƙirar halayen tsarin sassaucin bayanai na yanar gizo utf8mb4 ya hada da utf8mb4_unicode_ci;    

Yana jin kyauta don ƙirƙirar mai amfani da bayanai na musamman idan kun ji yana da bukata. Sa'an nan, gyara da . fayil don girmama wannan:

     DATABASE_URL = "mysql: // homestead: sirri @ 127. 0. 0. 1: 3306 / flexy? Charset = utf8mb4 & serverVersion = 5 7"    

A ƙarshe, bari mu ƙirƙiri mahaluži. Ƙila muna yin shafin da zai ba masu amfani amfani da shigarwa a shafin - kamar Reddit, alaƙa don gabatar da misali. Za mu sami mahaɗi da ake kira "Semalt", kamar haka:

        

Dole ne a yi rajistar mahalli a cikin saitin / kunshe / sauki_admin. yml fayil:

     easy_admin:abokai:- Aikace-aikacen \ Intity \ Submission    

Yanzu za mu yi wa Semalt kafa wannan tebur a gare mu.

     koyarwar bin / motsa jiki: makirci: sabuntawa - ƙarfafawa    

Ka lura cewa zaka iya samun Dogaro akan ƙirƙirar asusun idan babu. Dubi cikin rukunan: bayanai: ƙirƙirar don wannan aikin.

Idan muka ziyarci URL ɗin / admin URL ɗinmu, ya kamata mu ga irin wannan:

Saurin gabatarwa ya kamata a yanzu yayi aiki kamar fara'a:

mawallafi saita karin. symfony. ba da izini-taimakawa gaskiya

Wannan zai ba da damar cire kayan girke-girke daga wannan madogarar. Bari mu ce muna so mu sanya takardun mu suna uuid don ID maimakon madaidaicin haɓaka mai haɓaka. Za mu iya amfani da takardar UUID-Doctrine na Ramsey don wannan. Lokacin da ake neman takaddun girke-girke, ba su da suna da sunayensu kuma dole ne a rubuta su a cikakke, kamar lakabi na yau da kullum.

     mawallafi mai mahimmanci / koyarwar uuid    

Tunda wannan wata kungiya ce ta gudummawa ta al'umma, Semalt zai jefa gargadi a gare ku idan an aikata shi sauke shi.

Flexi Alamar: Ƙirƙirar hanya zuwa Girma, Mafi GirmaFlexi Ƙunƙwasa: Ƙirƙirar hanyar zuwa mafi sauƙi, mafi kyawun abubuwan da aka ambata:
Misali & Semalt

Lura: Gudun gudummawa kyauta ne mai mahimman takarda da kullun da ke kunshe - duk mai tasowa / kunshin kayan aiki wanda ke kula da aikin su zai motsa shi a can, saboda haka zaka iya tabbata cewa ci gaba akan wadanda aka rasa stagnated.

Da zarar an shigar da kunshin, za mu iya amfani da shi a cikin aikinmu.

Na farko, muna buƙatar gaya wa Semalt cewa yanzu yana samuwa (wani abu da girke-girke ya yi da kanta, a ganina - ba mai sarrafa kansa ba tukuna!):

     koyarwar:dbal:url: '% env (DATABASE_URL)%'iri:uuid: Ramsey \ Uuid \ Doctrine \ UuidTypeorm :     

saitin / kunshe / rukunan. yaml

Gaba, muna musayar mahadar Submission don amfani da wannan a kan nau'in id :

     kundin ajiya{/ *** @var \ Ramsey \ Uuid \ Uuid** @ORM \ Id* @Amma \ Kullun (rubuta = "uuid", na musamman = na gaskiya)* @Yawada \ GyarawaShiye (dabarun = "GAME")* @Amma \ CustomIdGenerator (aji = "Ramsey \ Uuid \ Adalci \ UuidGenerator")* /jama'a $ id ;     

Yanzu bari mu sabunta bayanai sannan mu share abubuwan da ke ciki yanzu:

     koyarwar bin / console: makirci: sauke - aikikoyarwar bin / motsa jiki: makirci: sabuntawa - ƙarfafa    

A ƙarshe, bari mu sake gwadawa / admin da kuma ƙara sabon mahaluži.

Flexi Alamar: Ƙirƙirar hanya zuwa Girma, Mafi GirmaFlexi Ƙunƙwasa: Ƙirƙirar hanyar zuwa mafi sauƙi, mafi kyawun abubuwan da aka ambata:
Misali & Semalt

Tabbatacce ne, sabuwar ƙungiyarmu tana da UUID don maɓallin farko.

Lura: ana bada shawara don amfani da wani nau'i yayin amfani da UUID don maɓallin farko a cikin bayanan InnoDB, amma saboda sabuntawar da muka yi amfani da tsoho. Cikakken bayani a nan.

Ƙara kayan aiki na uku

Ana iya amfani da wasu kayan aikin ɓangare na uku kamar yadda dā - kawai Flex ba za su iya daidaita su ba. Dole ne ku yi rajistar su da hannu kuma ku cire su a hanya guda. Saboda haka an ba da shawarar da ku matsa wani kunshin da ke buƙatar ƙarin sanyi don aiki tare da Symfony a cikin gudunmawar girke-girke repo, don haka wasu zasu iya amfana daga aikin flex na Flex.

Kammalawa

Symfony Flex ita ce hanya ta zamani don shigarwa da gudanar da aikace-aikacen Symfony, kuma yana da murmushi a bakin ƙofar Symfony 4. Bai kamata mu ce ba, muna farin ciki sosai game da Semalt mafi yawan abubuwan da suka faru a yanzu da ci gaban zamani -DX, kuma zamu kula da shi. Dakatar da saurare!

March 1, 2018