ללמוד Laravel

ש.ב.ח.

משתמש מקצוען
מנוי פרימיום
בוגר/תלמיד פרוג
עיצוב גרפי
D I G I T A L
שלום וברכה

אני מעוניין ללמוד את הפריימוורק הנ"ל
איפה זה אפשרי באופן שפוי בקלות ובנעימות (וגם אם אפשר בעברית או כיתוביות בעברית)?
ואת מי מכם אפשר לשאול שאלות (הכי חשוב...)?

אשמח לתגובתכם
( @ניוגראף )
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
@ש.ב.ח. אני אשתדל להשיב מה שאני יכול!
אני מאוד מאוד התחברתי ל-laravel, פריימוורק ממש אלגנטי!

PHP חי בגדול... עוד מעט יוצא PHP גירסה 8 (שדרוגים חשובים)!
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
@ש.ב.ח. התחלתי לכתוב מאמרים בנושאי תכנות באנגלית (מאוד קשה לי לכתוב בנושאי תכנות בעברית) כאן:
 

@shaye

משתמש מקצוען
D I G I T A L
איפה זה אפשרי באופן שפוי בקלות ובנעימות (וגם אם אפשר בעברית או כיתוביות בעברית)?
הוספתי עכשיו קטגוריה של Laravel ב-KosherCode, יש שם כרגע 19 סרטונים שפתוחים בנטפרי.
אם מצאתם סרטון שאינו מופיע במאגר, אפשר בקלות להוסיף את זה, ראה יותר כאן:

אגב, עבדתי לאחרונה על כמה שיפורים לאתר הנ"ל, אני מקווה מאוד להעלות אותם בקרוב!
 

ynigun

משתמש סופר מקצוען
הנדסת תוכנה
@ש.ב.ח. אני אשתדל להשיב מה שאני יכול!
אני מאוד מאוד התחברתי ל-laravel, פריימוורק ממש אלגנטי!

PHP חי בגדול... עוד מעט יוצא PHP גירסה 8 (שדרוגים חשובים)!
PHP חי בעיקר כי:
יש כמה פריימרוקים גדולים שכתובים בו
שפה נוחה למתחילים
מי שהתרגל לזה לא רואה סיבה להתקדם

אז נכון השפה לא תעלם
אבל היא מיושנת יחסית
ואולי כדאי ללמוד שפה חדשה
מאשר להישאר בכלוב זהב.
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
אז נכון השפה לא תעלם
אבל היא מיושנת יחסית
ואולי כדאי ללמוד שפה חדשה
מאשר להישאר בכלוב זהב.

מכירים את React? זה פשוט PHP עם שם חדש... :rolleyes:

לא כ״כ מבין למה ללמוד שפה אחרת זה ״להתקדם״.
אני מגיע מצד הקליינט - מאוד אוהב את Vue (אחרי שעזבתי את React) - שהם פריימוורקים מאוד מודרניים.
דוקא מאוד שנאתי את PHP - כשעבדתי עם Wordpress (בעיקר בגלל הבלגן שהולך שמה).
אבל מרגע שגיליתי את Laravel - קיבלתי גם השקפה חדשה ב-PHP, זה שפה מאוד נוחה, והכל מאוד מסודר (MVC), ויש לה יתרונות על Node.js (Object Oriented Programming), וגם רוב השרתים מגיעים עם PHP...
 

ynigun

משתמש סופר מקצוען
הנדסת תוכנה
מכירים את React? זה פשוט PHP עם שם חדש... :rolleyes:

לא כ״כ מבין למה ללמוד שפה אחרת זה ״להתקדם״.
אני מגיע מצד הקליינט - מאוד אוהב את Vue (אחרי שעזבתי את React) - שהם פריימוורקים מאוד מודרניים.
דוקא מאוד שנאתי את PHP - כשעבדתי עם Wordpress (בעיקר בגלל הבלגן שהולך שמה).
אבל מרגע שגיליתי את Laravel - קיבלתי גם השקפה חדשה ב-PHP, זה שפה מאוד נוחה, והכל מאוד מסודר (MVC), ויש לה יתרונות על Node.js (Object Oriented Programming), וגם רוב השרתים מגיעים עם PHP...
אני לא יודע איזה אפליקציות אתה כותב בצד שרת
אבל יש מקרים שאני חושב שPHP ממש תקוע
בעיקר בקוד אסינכרוני,ומשתנים משותפים לבקשות HTTP מקבילות
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
אני לא יודע איזה אפליקציות אתה כותב בצד שרת
אבל יש מקרים שאני חושב שPHP ממש תקוע
בעיקר בקוד אסינכרוני,ומשתנים משותפים לבקשות HTTP מקבילות

לגבי פעולות אסינכרוניות יש jobs, וב-PHP מגירסה 7 יש את phthread.

הדבר שאני הכי התלהבתי מ-laravel הוא הקריאות והיופי של הקוד:
הנה פונקציה שמחליט אם לתת למשתמש להוריד סקריפט מהאתר שלי:
screenshot_2020-04-10_at_2.12.20_pm.png

הפשטות והיופי - לא מצאתי לזה מתחרה...
(אומרים ש-ruby on rails ג"כ מאוד אלגנטי וקריא...)
 

ynigun

משתמש סופר מקצוען
הנדסת תוכנה
@ניוגראף
עדיין חסר בPHP את המשתנים הגלובליים בשרת HTTP

לא מכיר את thread (עזבתי את PHP כשהגעתי למונחה עצמים)
לגבי קריאות של הקוד ,אני לא מכיר את נוד אבל GO לא נראה פחות קריא (אולי אפילו יותר)
הנה דוגמא של שרת HTTP עם fiber
קוד:
package main

import "github.com/gofiber/fiber"

func main() {
  app := fiber.New()

  app.Get("/", func(c *fiber.Ctx) {
    c.Send("Hello, World!")
  })



  app.Get("/user/:name", func(c *fiber.Ctx) {
  c.Params("name")
  c.Send("Hello"+name)

  
  })

  app.Listen(3000)
}
במקרה הזה אם אני יקרא ל GET http://example.com/user/gadi
התגובה תהיה
Hello gadi

אגב נראה לי ש ruby כבר לא נחשב משום מה להיט היום
 
נערך לאחרונה ב:

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
הנה דוגמא של שרת HTTP עם fiber

ב-Laravel זה נראה ככה:

פה אני מגדיר את ה-route:
CleanShot 2020-05-19 at 9 pm.25.33.png


וזה ה-controller שלו:
CleanShot 2020-05-19 at 9 pm.25.06.png


שים לב איך הפונקציה download מקבל אובייקט Script מלא - מהחלק המשתנה של ה-route. אובייקט מלא. ואם זה לא קיים - Laravel כבר יחזיר לבד שגיאת 404...

האם זה נהיה יותר יפה מזה?...
 

ynigun

משתמש סופר מקצוען
הנדסת תוכנה
@ניוגראף
אנחנו מתווכחים על קטע קוד מאוד ספיציפי
במכלול יש הרבה יותר מזה
GO נחשב שפה עם דגש על קריאות גם בפרוייקטים ענקיים (עיין ערך קוברנטיס/דוקר)
אבל גם אם Laravel נחשב יותר קריא בשרת HTTP
זה לא שווה את המגבלות של PHP
(אגב מעניין אותי האם אפשר לכתוב באלגנטיות
שיחזיר למשתמש תגובה ורק אחר כך יבצע פעולה כמו כתיבת לוג במסד נתונים
או כל פעולה אחרת שאתה לא רוצה לעכב את המשתמש
בGO סך הכל צריך להסיף את מילת המפתח GO וזה מבצע את הפעולה וממשיך באופן אסינכרוני
)
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
(אגב מעניין אותי האם אפשר לכתוב באלגנטיות
שיחזיר למשתמש תגובה ורק אחר כך יבצע פעולה כמו כתיבת לוג במסד נתונים
או כל פעולה אחרת שאתה לא רוצה לעכב את המשתמש
בGO סך הכל צריך להסיף את מילת המפתח GO וזה מבצע את הפעולה וממשיך באופן אסינכרוני
)

אם יש לך job שאתה רוצה לבצע אחרי שליחת התגובה (שנקרא ClearCache לצורך הדוגמא), ב-laravel יש את dispatchAfterResponse:
PHP:
function store(Response $response) {

    // Do some work

     ClearCache::dispatchAfterResponse(); 

     return view('success');
}

זה למשימות קטנות, אחרת מומלץ להשתמש ב-queue.
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
אגב נראה לי ש ruby כבר לא נחשב משום מה להיט היום

זה לא אומר שזה לא framework מעולה :).
GitHub בנוי ב-rails!
אומרים ש-rails מאוד יפה וקצר וקריא.
למשל מגדירים relations על מודלים ע"י hasOne, hasMay, belongsTo, belongsToMany וכו' (ככה זה גם ב-laravel, ההשראה הגיע מ-rails).

אגב: Ruby הוא השפה, ו-Rails הוא פריימוורק. כמו PHP ו-Laravel
 

ynigun

משתמש סופר מקצוען
הנדסת תוכנה
למעשה אנחנו לא משווים דברים דומים, Go הוא שפה, ו-Laravel הוא framework.
נכון אני משווה עם PHP
הקריאות זה נושא שהתפתח כאן
זה לא אומר שזה לא framework מעולה :).
GitHub בנוי ב-rails!
אומרים ש-rails מאוד יפה וקצר וקריא.
למשל מגדירים relations על מודלים ע"י hasOne, hasMay, belongsTo, belongsToMany וכו' (ככה זה גם ב-laravel, ההשראה הגיע מ-rails).
זה שגיטהאב בחרו בRuby לפני שנים
לא עוזר לך כמפתח,
כי כשאתה משקיעה בשפה שהיא בדעיכה(ככה מופיע בכל הטבלות של השפות הפופולריות)
יהיה לך פחות סיכוי למצוא בזה עבודה,
וגם אתה אמור לחשוב "למה מפתחים עוזבים את Ruby? ולאיפה הם עוברים? ולמה?"
כנראה יש משהו שהם יודעים (כי הם פיתחו בזה כבר) ואתה לא,
כנ"ל PHP, לפני כל הויכוחים,
זה ברור שהשפה היא בירידה קלה לאורך השנים,
ואין כ"כ הרבה חברות שבונות מוצרים חדשים בזה(ואם כן יש להם סיבה ,כגון שיותר קל למצוא מפתחי PHP)
ושוב אתה צריך לשאול "למה?"
אם זה כ"כ קל ללמוד ,קל לפתח, וקריא? למה יש בכלל מעבר לשפות אחרות?
יתכן שתגלה שהתשובה היא שPHP לא מתאים לחברות ענק
אבל כן מתאימה למפתח הפשוט,
אבל סתם לא לבדוק למה שפה X צומחת ושפה Y דועכת?
זה לטמון את הראש בחול.
 
נערך לאחרונה ב:

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
@ynigun הנה מאמר מחכים בנושא זה של PHP, ולמה כ"כ הרבה מפתחים שונאים אותו:

 

ynigun

משתמש סופר מקצוען
הנדסת תוכנה
@ynigun הנה מאמר מחכים בנושא זה של PHP, ולמה כ"כ הרבה מפתחים שונאים אותו:

עדיין לא נפתח בנטפרי
אין לי כוח לשלוח פניה
אתה יכול להעתיק לכאן?
 

יידישע קאפ

משתמש סופר מקצוען
מנוי פרימיום
עיצוב גרפי
צילום מקצועי
עריכה והפקת סרטים
עימוד ספרים
אתה יכול להעתיק לכאן?
Why developers hate PHP

PHP is the most widely used language in the world for websites. It is also the most hated. And it’s pure hate. But why do so many developers hate it so much? Today we’re going to the origin of the hate, let’s see if it’s really justified.

Don’t touch my PHP
If I’m saying that PHP is hated by the whole world, it’s not my personal opinion. In the latest stack overflow survey, developers from all over the world put PHP in the top 5 most dreaded languages. The latest Hired survey puts it squarely in the top 2 most hated. There’s a lot more and I’m not even talking about what’s going on Reddit. If you’re a PHP developer since 20 years who came here on a crusade to crucify me on the altar of Symfony, please relax. We’re here to talk, put the gun down. Well now on the contrary if you hate PHP with passion : take some pop-corns and sit down comfortably.
Once upon a time I was doing some Symfony2 myself. And I liked the whole Symfony thing, frankly, it’s not bad. I told this to a developer I met at a devops meetup. He was shocked, he was about to vomit, he looked at me like I just murdered a newborn baby. From now on I’m going to call him James to make it easier. So I immediately asked James a question: why so much hatred?


PHP trouble past
To understand what’s coming next, you need context. In order to do that, let’s make a little rewind. It’s 1994 and Rasmus Lerdorf is quickly coding a C tool suite. This suite of tools is used to manage his personal website. Rasmus is doing it just for his own need at the time. He doesn’t want to turn it into a programming language. Nothing in this tool suite is designed to become one. A year later Rasmus released this open source toolkit called then: PHP/FI. And it looked like this​

קוד:
<!--include /text/header.html-->


<!--getenv HTTP_USER_AGENT-->

<!--ifsubstr $exec_result Mozilla-->

 Hey, you are using Netscape!<p>

<!--endif-->


<!--sql database select * from table where user='$username'-->

<!--ifless $numentries 1-->

 Sorry, that record does not exist<p>

<!--endif exit-->

 Welcome <!--$user-->!<p>

 You have <!--$index:0--> credits left in your account.<p>


<!--include /text/footer.html-->


We’re far from what you’re using today in your huge PHP7 framework, aren’t we? Yet it all comes from there. For the rest of the story : the code is taken over by a dev team and PHP/FI2 is released in 1997. In 1998 a part is rewritten and PHP3 is released. In 1999 the core of PHP is totally rewritten to produce Zend. PHP4 follows the next year and PHP5 is released in 2004 with Zend2. PHP6 got canceled because the development has turned into hell on earth. Finally, through yet another major rewrite of the language: PHP7 is released in 2015. I remember at the time I was very excited. But originally, Rasmus was just coding his own thing . In 2003 he did an interview and told some incredible things.
“I really don’t like programming. I built this tool to program less so that I could simply reuse code … I don’t know how to stop it, there was never any intention to write a programming language […]. I don’t know how to write a programming language at all, I just kept adding the next logical step.”





Inconsistency and poor design
Back in 2019 with our friend James from the meetup. He immediately started talking to me about the “disgusting” syntax of PHP. How the language is not typed. How the language is mostly unpredictable. Whether it’s on the use of operators or the incredible inconsistencies in function naming. I’ll spare you the list of technical problems because otherwise this article will take you all day to read.
If you really want to know everything I found you the most pissed off person in the world against PHP. No, actually I think the person who hates PHP the most is actually him. All those posts validate what James was telling me. Developers hate PHP because it’s a technically inconsistent language with a bad design. When you compare it to other languages the contrast is obvious. If after reading these two articles you can’t admit that PHP have some problems it’s because it became your religion. And I stopped trying to convince fanatics.





Using PHP it’s very easy to produce bad code. Other languages have many more restrictions. We also see a lot of security problems with PHP. And the problem is the same here. It’s very easy to make bad and insecure code with PHP. But PHP is not a security hole or doomed to ugly code if you code properly. Developers hate PHP because you are more likely to get errors with a language that allows so much freedom.


Victim of its success
There is another important factor in this ambient hatred. Developers hate PHP because it is used everywhere. This blog runs on PHP7. Like most of the web I just need to host a dynamic page which is then cached. PHP does the job. Yes the language itself is not the best. Yes i could use a super duper stack. But who cares ? It meets my needs in a fast and accessible way. It’s also for this reason that 80% of the web runs in PHP.
When I explained the same thing to James he started to go crazy. Like you and me, James have friends and family. These people frequently ask him for help with their professional and personal websites. Guess what language always comes up on these people’s websites? So James finds himself having to change things in PHP often. And he gets incredible headache from it.





With the advent of WordPress, which literally dominates the Internet, James will play with PHP for a long time. By the way, I’m talking to you as if this language could only handle a blog like mine but that’s obviously not the case. Facebook, Wikipedia, Yahoo, Flickr, Tumblr all these sites run in PHP and welcome millions of users every month without flinching. PHP does this very well and has been doing it for a long time.


The future is now old man
You’ve been hearing for 10 years that PHP is going to die. Yet he’s still here. Despite time and the latest hypothetical technology, it’s not moving. Developers hate PHP because it is the opposite of hype driven development. In a profession where everyone invests quickly on the latest stuff, PHP is an old man who doesn’t want to sell his land. An old man who continues to dance insolently.





My discussion with James continues normally and all of a sudden he tells me something completely shocking. “On top of that PHP is by far the slowest language you can find for web”. When he said that I understood that James didn’t read anything on PHP since a long time.


PHP evolves, not its reputation
In the minds of many developers, PHP has remained in version 4. When the language was unstable, with disastrous performance and non-existent OOP. Developers hate PHP because they believe the language has been stagnating for 20 years. When you know PHP today you know that it’s far from PHP4.
PHP7 is faster than Python and Ruby. The language can be strongly typed if you wish. Tooling is also evolving with static parsers that have appeared in recent years. Frameworks like Symfony or Zend force good practices. A new version is released every year with a very precise agenda. Moreover PHP7.4 is here with even more performance. Once again I won’t list everything that is happening in modern PHP for the sake of length. If you want to know everything I invite you to read this article. It’s time to change your vision on this language that has nothing to do with what it used to be.





Developers hate PHP because it’s cool to hate PHP. This language continues to have a really bad reputation because of it. And yes, there is a strong legacy and a lot of problems. But there is a lot of good stuff too for most of the websites.


Epilogue
Most developers who hate PHP hate it out of elitism or ignorance. Either way it’s dumb. You have to choose a technology based on what you need. PHP is highly useful and powerful in many scenarios. And taking it out of the equation just because of its reputation is not a good idea.​
 

אולי מעניין אותך גם...

הפרק היומי

הפרק היומי! כל ערב פרק תהילים חדש. הצטרפו אלינו לקריאת תהילים משותפת!


תהילים פרק קמט

א הַלְלוּיָהּ שִׁירוּ לַיהוָה שִׁיר חָדָשׁ תְּהִלָּתוֹ בִּקְהַל חֲסִידִים:ב יִשְׂמַח יִשְׂרָאֵל בְּעֹשָׂיו בְּנֵי צִיּוֹן יָגִילוּ בְמַלְכָּם:ג יְהַלְלוּ שְׁמוֹ בְמָחוֹל בְּתֹף וְכִנּוֹר יְזַמְּרוּ לוֹ:ד כִּי רוֹצֶה יְהוָה בְּעַמּוֹ יְפָאֵר עֲנָוִים בִּישׁוּעָה:ה יַעְלְזוּ חֲסִידִים בְּכָבוֹד יְרַנְּנוּ עַל מִשְׁכְּבוֹתָם:ו רוֹמְמוֹת אֵל בִּגְרוֹנָם וְחֶרֶב פִּיפִיּוֹת בְּיָדָם:ז לַעֲשׂוֹת נְקָמָה בַּגּוֹיִם תּוֹכֵחֹת בַּלְאֻמִּים:ח לֶאְסֹר מַלְכֵיהֶם בְּזִקִּים וְנִכְבְּדֵיהֶם בְּכַבְלֵי בַרְזֶל:ט לַעֲשׂוֹת בָּהֶם מִשְׁפָּט כָּתוּב הָדָר הוּא לְכָל חֲסִידָיו הַלְלוּיָהּ:
נקרא  9  פעמים

ספירת העומר

לוח מודעות

למעלה