• The Entrepreneur Forum | Startups | Entrepreneurship | Starting a Business | Motivation | Success
  1. Join 40,000+ entrepreneurs
    who are kicking butt and
    winning their dream life.

    Unscripted™ Entrepreneurship:
    A Business That Pays More Than Money, It Pays Time.

    "Fastlane" is an entrepreneur discussion forum based on The Unscripted Entrepreneurial Framework (TUNEF) outlined in the two best-selling books by MJ DeMarco (The Millionaire Fastlane and UNSCRIPTED™). From multimillionaires to digital nomads, the forum features real entrepreneurs creating real businesses.

    Download (Unscripted) Download (Millionaire Fastlane)  Register
    Registering for the forum removes this block!

Web Programming with PHP (guide for non-engineers)

Discussion in 'General Entrepreneur Discussion' started by ApeRunner, Oct 7, 2018.

  1. ApeRunner
    Offline

    ApeRunner Very Fast on a Bike Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    149
    Likes Received:
    443
    Joined:
    May 16, 2014
    Gender:
    Male
    Location:
    Cozumel
    Rep Bank:
    $4,836
    Are you ready to start programming?
    8594455273_23f87d3daf_b.jpg


    Many people in this forum want to get started on programming. In this thread, I will teach you how to program in the PHP language. Why PHP? Because is powerful, easy to learn and has the best community (compared to other languages).

    I have been programming in PHP for more than ten years now, and it appears I will never stop doing it. It’s just a super useful skill for an entrepreneur. I have various business and websites running and I program for all of them at different levels and circumstances.

    I know there are other languages to program for the web: Python, Ruby, C-sharp, etc. But I recommend PHP for entrepreneurs. Why? Because…

    PHP is Powerful

    Empires have been started/created with PHP. This language has humble beginnings and started more than two decades ago as a “Personal Home Page” pre-processor. But now is a very mature language with a fast runtime (PHP 7) and a full object-oriented model.

    These are some of the projects/companies that started with PHP:

    · Facebook: One of the most powerful companies in the world.

    · WordPress: Its software is said to power 80% of the world’s web pages.

    · Magento: The most advanced e-commerce shopping cart. Recently acquired by Adobe for $1.68 Billion (USD).

    · XenForo: This forum.

    Also used by Slack, Etsy, Wikipedia, Tumblr and lots of sites.

    In my 15 years of using PHP I have never encountered a situation where I couldn’t solve it with PHP. Of course, I have to complement it with JavaScript on the front-end, as is commonly done.

    PHP is Easy to Learn

    This is one of the main advantages for the language. I think the common profile of the PHP coder is that, we, come from non-engineering careers. The learning curve is low compared to other languages such as Python.

    If you are an entrepreneur, you don’t have the time to spend years learning a technical skill. Because you’ll be wearing many hats. And you have to be fast delivering results (minimum viable product?).

    We entrepreneurs are not specialists but generalists. We have to keep the big picture. With PHP you don’t have to spend all your life in the technical space.

    When I got my first job as a coder, I learned to program in PHP in a matter of months. And delivered results for the company that hired me. As years passed I became a better coder. And with PHP you can evolve to more complex coding.


    PHP has the Best Coding Community

    I have not experienced this at first hand, but my coder friends tell me that the PHP community is more friendly than the communities of other languages. I think is because we PHP coders don’t pretend to be perfect engineers. We just want to get the job done. As a result of this, there is a lot of resources along the internet and the PHP Conferences around the world are thriving and very welcoming.

    There are more open source projects in PHP than any other language. A lot of the most successful open source projects are made with PHP:

    · E-Commerce: Magento, WooComerce, PrestaShop, OpenCart…

    · Content Management: WordPress, Drupal, Joomla, ProcessWire (awesome framework)…

    · General purpose frameworks: Symphony, Laravel, CodeIgniter, Phalcon, Yii, Zend, CakePHP...

    · As well lots of components for every necessity.

    PHP has a thriving, open source and friendly community. The majority of web hosts already have support for PHP and it’s database sister MySQL. So you can start right away.


    Warning: Haters gonna hate
    1_lczk5cwMcnRm-MrIUp9trg.png


    Some “real” software engineers criticize PHP because is not “perfect”. Because PHP doesn’t have a beautiful syntax as Ruby. Or is not a secure as Python (if you don’t know what are you doing).

    What I think is that these people (snobs?) envy us. Because us PHP coders, without “proper training” are doing great stuff and still have time for doing other things (like marketing). A great part of the internet is powered by PHP. It just works.

    Haters understand: We entrepreneurs that use PHP are not trying to create beautiful and perfect code. We are focused on creating business and this programming language is just a practical tool to get the work done. Fast. Just ask Mark Zuckerberg.


    A personal take

    I will use this thread as some kind of brain-dump. My perspective will be as a lone coder. And I will share the tools and techniques that work for me. Of course out there are hundreds of different applications.

    I just hope to help you that are starting and have no clue about PHP.

    Feel free to ask any question regarding the language. What I can’t do is review any piece of code. That would be impossible for me.

    I will start to create new posts about different aspects of the language in the next days.


    PS: I make this thread with the hope for helping fellow entrepreneurs. Also to respond to @LightHouse's challenge about trying to create a gold thread (last 2018 summit).
     
    Last edited: Oct 13, 2018 at 11:32 PM
    Zhyna, ZF Lee, 404profound and 8 others like this.
  2. George Appiah
    Online

    George Appiah Bronze Contributor Read Millionaire Fastlane I've Read UNSCRIPTED Speedway Pass

    Messages:
    79
    Likes Received:
    119
    Joined:
    Aug 16, 2018
    Gender:
    Male
    Location:
    Accra, Ghana
    Rep Bank:
    $1,084
    Following!

    I was scheduled to travel to Vancouver, BC, Canada in September for a 1-year coding boot camp + internship with Red Academy. Spent over $1K on various VISA-related fees (application fee, biometric fee, medical tests, consultation, a truck-load of documentation, etc) --- and despite paying my fees in full, my visa application was denied... for not demonstrating I had access to sufficient funds to support myself in Canada (funny, as my application included a certified bank statement with over US$50k (equivalent) closing balance).

    This was a triple play: my goals were to immerse myself fully in coding for a period of time (that's' why I wanted to be away from the family), get some real-world experience in a startup or agency setting, and accumulate points for "Canadian study/work experience" that I would use in a future skilled-worker immigration application.

    I also wanted to test out if Vancouver is all it's cracked up to be, as that's the city I wanted to settle in... someday.

    I'm currently following freeCodeCamp's coding projects, but I'll surely re-apply next year.

    Looking forward to your future posts in this thread!
     
    Last edited: Oct 8, 2018
  3. lowtek
    Offline

    lowtek Platinum Contributor Read Millionaire Fastlane FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    892
    Likes Received:
    2,913
    Joined:
    Oct 3, 2015
    Gender:
    Male
    Location:
    Phoenix, AZ
    Rep Bank:
    $17,825
    I always laugh at those that say PHP is dead.

    I never learned it, because I'm not really a web guy, but I'm not gonna hate on it. It's a general purpose language that powers much of the web.

    Look forward to reading the thread!
     
    ZF Lee and ApeRunner like this.
  4. lowtek
    Offline

    lowtek Platinum Contributor Read Millionaire Fastlane FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    892
    Likes Received:
    2,913
    Joined:
    Oct 3, 2015
    Gender:
    Male
    Location:
    Phoenix, AZ
    Rep Bank:
    $17,825
    I did some of free code camp's stuff, and found it really valuable (that's how I discovered I'm not a web guy). I think if you complete it and make the most of it, you probably won't need the paid boot camp.

    Moving to Canada from Ghana may require it, but your skill set will be up to par after finishing FCC.
     
    ZF Lee, ApeRunner and George Appiah like this.
  5. Smuggo
    Offline

    Smuggo Contributor Read Millionaire Fastlane I've Read UNSCRIPTED

    Messages:
    26
    Likes Received:
    20
    Joined:
    Apr 13, 2018
    Gender:
    Male
    Rep Bank:
    $107
    I think most people don't like PHP since it's really easy to make many errors. It's interpreted so you can make a mistake and still don't know about it until you check it on the website and then, bang, something crashed. Also for large applications it's really hard to operate on PHP code and a lot of developers are NOT doing XUnit testing... which is something fundamental. I had a lot of reschuldes in my previous work because frontend was messing around. :p
     
    LittleWolfie likes this.
  6. ApeRunner
    Offline

    ApeRunner Very Fast on a Bike Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    149
    Likes Received:
    443
    Joined:
    May 16, 2014
    Gender:
    Male
    Location:
    Cozumel
    Rep Bank:
    $4,836
    06164e5499445c9d3614c6608ac489da17b3696357ce076685142db1b26f4f5a.jpg
     
    Last edited: Oct 8, 2018
  7. TinyOldLady
    Offline

    TinyOldLady Bronze Contributor Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass

    Messages:
    95
    Likes Received:
    193
    Joined:
    Oct 27, 2017
    Gender:
    Female
    Location:
    Germany
    Rep Bank:
    $315
    Thank you very much, @ApeRunner , I'll follow this thread. Currently I program in JavaScript and have no clue about PHP
     
    ZF Lee and ApeRunner like this.
  8. eliquid
    Offline

    eliquid ( Jason Brown ) Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass LEGENDARY CONTRIBUTOR

    Messages:
    1,193
    Likes Received:
    5,409
    Joined:
    May 29, 2013
    Gender:
    Male
    Location:
    Louisville - Kentucky
    Rep Bank:
    $43,221
    Glad this is up. Love PHP.

    I've built pretty much everything I have coded in PHP since the days of FI.
     
    ZF Lee, andrewsyc and Andy Black like this.
  9. andrewsyc
    Offline

    andrewsyc Contributor Read Millionaire Fastlane I've Read UNSCRIPTED

    Messages:
    24
    Likes Received:
    42
    Joined:
    Aug 14, 2017
    Gender:
    Male
    Location:
    Iowa
    Rep Bank:
    $99
    PHP gets a bad rap but that's mostly because it's so easy to get up and going with it and thus there is so much sloppy code out there.
     
    ZF Lee likes this.
  10. Captain_Picard
    Offline

    Captain_Picard Contributor

    Messages:
    12
    Likes Received:
    21
    Joined:
    Aug 21, 2018
    Gender:
    Male
    Rep Bank:
    $107
    Thanks for posting this OP. What are some tips to be a better PHP programmer?

    Some general pointers I have come across are:

    1) Comment everything. Explain what you did, what does this variable mean, what does it do, why did you build this code structure, etc...

    2) Create from a security standpoint from the get-go. Regex, filter_var() everything coming in, sanitize every thing going out. Sanitize at the JavaScript level and sanitize at the backend.

    What are some other tips you would recommend to be a safer programmer and to be able to get an application built faster and better?
     
    ZF Lee likes this.
  11. Smuggo
    Offline

    Smuggo Contributor Read Millionaire Fastlane I've Read UNSCRIPTED

    Messages:
    26
    Likes Received:
    20
    Joined:
    Apr 13, 2018
    Gender:
    Male
    Rep Bank:
    $107
    Learn PHPUnit tests!:smile:
     
    TheSilverSpoon likes this.
  12. ApeRunner
    Offline

    ApeRunner Very Fast on a Bike Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    149
    Likes Received:
    443
    Joined:
    May 16, 2014
    Gender:
    Male
    Location:
    Cozumel
    Rep Bank:
    $4,836
    How to Start programming in PHP?

    You will need a web host that supports PHP. Most web hosting providers already do. There are literally thousands.

    Here is a list of popular web hosts:

    · HostGator
    · BlueHost
    · SiteGround
    · InMotion
    · iPage
    · A2 Hosting
    · DreamHost
    · MediaTemple

    Stay away from GoDaddy. This company is very popular for domain registration, BUT, their hosting services are awful.

    There are basically three levels for a web hosting account:

    Shared account
    Your site will be hosted among hundreds of other websites. So, this level is intended for websites with a lighter load of usage. You won’t have “root access”. That means you cannot install custom modules to your “server” and other advanced modifications.

    Virtual Private Server (VPS)
    Your site will still be hosted among other sites or “virtual servers”. But the number of neighboring accounts won’t be as big as in a shared account. You will have root access and can make modifications as if it were a single server for you.

    Dedicated Server
    A real server (machine) for you. You can configure your machine to your liking as in choosing RAM and hard disk options. You can make custom modifications to your server. Intended for websites with a heavy load of usage such as bigtime ecommerce sites.

    One of the most important things in deciding which hosting provider to use is customer support. You’ll need a host that you can call 24/7.

    Additionally, you could run PHP in a local environment (your PC) with a local server such as WAMP (Windows) or XAMPP (Windows, Mac, Linux).

    I personally only work on web servers since there is where my sites and applications will run. There always be differences and incompatibilities between your local server and the web server.

    How do I write the Code?

    You could use Notepad or any text editor to write PHP. But that is not advisable. What you really need is an “IDE” (Integrated Development Environment) that’s is suited for PHP.

    There are a lot of IDEs and text/code editor. I haven’t tried them all. But I’m pretty sure the best one is PHPStorm.

    PHPStorm
    phpstorm.png
    Is a complete solution for all things PHP. Is a commercial product developed by a Czech company named JetBrains. The software is very mature and easy to use. It has everything. You can upload your files directly by the FTP protocol to your server and stay in sync.


    Visual Studio Code code.png
    VS Code is a code editor developed by Microsoft. It’s free and everybody is loving it. It has its own marketplace of extensions where you can add functionality to the program. It already comes with a PHP extension for working in this language.

    You’ll have to be more of a techie to get started with VS Code.

    I recommend PHPStorm for the non-engineer types.

    Do you know a good hosting provider to recommend? Do you prefer another IDE or text editor for writing code?
     
    Zhyna and TinyOldLady like this.
  13. 404profound
    Online

    404profound Gold Contributor I've Read UNSCRIPTED Speedway Pass

    Messages:
    662
    Likes Received:
    1,405
    Joined:
    Aug 27, 2017
    Gender:
    Male
    Location:
    Desert of Desertion
    Rep Bank:
    $1,663
    Whatever you do, do not use Vim as an IDE
     
    GregDott and Andreas Thiel like this.
  14. MoneyPhantom
    Offline

    MoneyPhantom Contributor Read Millionaire Fastlane I've Read UNSCRIPTED

    Messages:
    32
    Likes Received:
    31
    Joined:
    Aug 6, 2017
    Gender:
    Male
    Location:
    Germany
    Rep Bank:
    $159
    Expect the stupidity of other programmers misusing your code.
    • Encapsulate everything into classes as good as possible (private/protected).
    • Make your code as fault tolerant as possible even on the internals.
     
  15. lowtek
    Offline

    lowtek Platinum Contributor Read Millionaire Fastlane FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    892
    Likes Received:
    2,913
    Joined:
    Oct 3, 2015
    Gender:
    Male
    Location:
    Phoenix, AZ
    Rep Bank:
    $17,825
    lol

    Vim is one of those things with a steep learning curve, but yields significant productivity benefits once you get over that curve. It's on my list of things to learn.
     
    daru, rogue synthetic and ApeRunner like this.
  16. LittleWolfie
    Offline

    LittleWolfie Bronze Contributor Read Millionaire Fastlane Speedway Pass

    Messages:
    563
    Likes Received:
    313
    Joined:
    Jun 28, 2018
    Location:
    Holbeach Hurn
    Rep Bank:
    $480
    I do wonder if HTML/Javascirpt has started making PHP obsolet enow. After all a lot that couldn't be done with html in 94, now can be downn with html/js. On the other hand their are a lot of technologies that rely on PHP and companies may wan to maintian old systems rather than switch to new ones.
     
  17. SoftStone
    Offline

    SoftStone Contributor Read Millionaire Fastlane

    Messages:
    60
    Likes Received:
    97
    Joined:
    Jan 15, 2018
    Gender:
    Male
    Location:
    Germany
    Rep Bank:
    $671
    HTML and JavaScript are frontend technologies. PHP is a backend technology. They're not competing. PHP can be used together with HTML to fetch the data from a database (PHP) and display it (HTML), for example. And HTML without PHP (or, for that matter, any other backend language) is only good for static websites. Check out my thread on web development, that may help you.

    And yes, you can use JS on the backend, too. However, there are dozens of more established technologies on the backend, although JS on the backend seems to get popular. But don't follow the hype for hype's sake. Have a reason.
     
    Last edited: Oct 14, 2018 at 1:34 PM
    GregDott, ZF Lee and ApeRunner like this.
  18. SoftStone
    Offline

    SoftStone Contributor Read Millionaire Fastlane

    Messages:
    60
    Likes Received:
    97
    Joined:
    Jan 15, 2018
    Gender:
    Male
    Location:
    Germany
    Rep Bank:
    $671
    Warning: this is going to get subjective...

    Please don't comment everything. Or by that regard, every variable. Code should be readable without comments that explain what it does. If you can't express yourself in code, why do you think you can express yourself in comments? :)

    It's better to comment why you did something, or give broad overviews of what specific files are for IMO. But not for every line.

    1. Use a good framework on the backend. If you don't screw everything up, you'll be way safer that way and ship faster.
    2. Learn about SQL Injection, XSS and other common security vulnerabilities
    3. What developers want to make, hackers want to break. You'll have to understand the latter as well in order to be safe.
     
    Last edited: Oct 14, 2018 at 1:13 PM
  19. eliquid
    Offline

    eliquid ( Jason Brown ) Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass LEGENDARY CONTRIBUTOR

    Messages:
    1,193
    Likes Received:
    5,409
    Joined:
    May 29, 2013
    Gender:
    Male
    Location:
    Louisville - Kentucky
    Rep Bank:
    $43,221
    Maybe this was accidently mis-wrote.

    But I write a ton of PHP that never touches or uses HTML. I have whole systems of PHP code that is just backend REST APIs and background processing via CMD line.

    Did you mis-type this?
     
  20. SoftStone
    Offline

    SoftStone Contributor Read Millionaire Fastlane

    Messages:
    60
    Likes Received:
    97
    Joined:
    Jan 15, 2018
    Gender:
    Male
    Location:
    Germany
    Rep Bank:
    $671
    Sorry, you're right. I meant that, in the context of just a basic web app, it wouldn't be useful to use PHP to fetch data from a database without actually displaying it with HTML.

    But yes, REST services that are meant to process or fetch some kind of data from 3rd party endpoints don't need HTML directly. Only at the end, it would be useful to actually display something to users on the web (if the API is meant for that purpose, and not a standalone product, which also exist)... that's what I meant but put in pretty lousy words ^^.

    Thanks for making me aware of that. Will go back and correct that.
     
    Last edited: Oct 14, 2018 at 1:42 PM
  21. garyfritz
    Offline

    garyfritz Bronze Contributor Read Millionaire Fastlane FASTLANE INSIDER

    Messages:
    522
    Likes Received:
    391
    Joined:
    Jul 16, 2011
    Location:
    Colorado
    Rep Bank:
    $3,236
    +1. I have a friend -- a professional software developer who's been a full-time programmer for 30 years -- who insists on commenting EVERYthing to an absurd degree. I mean like this:

    x = 0; // Set x to 0

    IMHO it's ridiculous and it's hard to see the logic of the program behind all the "noise" of his extraneous comments.

    That's closer to what I do. Give a brief description of what's happening before a section of code, with a short explanation of what you're doing and why. Those comments give a high-level view of what's happening in that section. You can understand a large piece of code by reading the comments associated with each "paragraph," only diving into the code for sections you need to understand in detail.

    With that introductory comment, the code in the section should be easy to understand. If something in the section isn't obvious, go ahead and add a comment to that code. Something like this:

    // Frobunize the encabulator, then use it to build the next radial wotsit.
    // Once we have enough wotsits, feed them into the augmented flappenizor.

    Encab = x + y / 23;
    Ulate = sin(time_seconds); // Determine the rotational velocity of time
    Whatever = Frob(Encab, Ulate);

    Wotsits[Wots++] = HypergolicInverse(Whatever);
    if (Wots > Enough)
    Flappen(Wotsits);
     
    daru, jon.M and SoftStone like this.
  22. SoftStone
    Offline

    SoftStone Contributor Read Millionaire Fastlane

    Messages:
    60
    Likes Received:
    97
    Joined:
    Jan 15, 2018
    Gender:
    Male
    Location:
    Germany
    Rep Bank:
    $671
    Let's not get too nit-picky in this thread, but in that scenario, I'd probably create a function called frobunizeEncabulator() or something like that instead of commenting.

    For anybody reading: I'd recommend Clean Code by Robert Martin if you want to improve your coding style. Great read. Although the examples are written in Java, they apply to pretty much any language.
     
    daru and ZF Lee like this.
  23. garyfritz
    Offline

    garyfritz Bronze Contributor Read Millionaire Fastlane FASTLANE INSIDER

    Messages:
    522
    Likes Received:
    391
    Joined:
    Jul 16, 2011
    Location:
    Colorado
    Rep Bank:
    $3,236
    Yes. If the variables / functions can be self-documenting, they should be. I was trying to convey a more complex logic flow than could be captured in individual names, without making my example too large.
     
  24. LittleWolfie
    Offline

    LittleWolfie Bronze Contributor Read Millionaire Fastlane Speedway Pass

    Messages:
    563
    Likes Received:
    313
    Joined:
    Jun 28, 2018
    Location:
    Holbeach Hurn
    Rep Bank:
    $480
    JavaScript isn't a front end technology, it is used commonly on the front end though.

    That's how you know it isn't a front end technology, you can't use HTML on the back-end.

    Though for a basic understanding your approach is perhaps an acceptable oversimplification, it just hit a personal hot button for me.

    They are, because you can use a MEAN stack instead of a LAMP stack.
    I agree. A requirement to access the local data or camera/audio on a device is a good reason to use JS. Or maybe using it is in your specification. If it's the language your most familiar with that's a another good reason of course.


    Probably, because any professional can quickly and easily ignore or toggle off all those comments.
     
  25. ApeRunner
    Offline

    ApeRunner Very Fast on a Bike Read Millionaire Fastlane I've Read UNSCRIPTED FASTLANE INSIDER Speedway Pass Summit Attendee

    Messages:
    149
    Likes Received:
    443
    Joined:
    May 16, 2014
    Gender:
    Male
    Location:
    Cozumel
    Rep Bank:
    $4,836
    @LittleWolfie How do your comments HELP non-engineers that DO want to learn PHP?

    Because if you want to talk about JavaScript this is no the thread for that.
     

Share This Page