Where Laravel developers feel right at home It can sometimes feel like the documentation skips a few steps here and there. Other times, the documentation can feel overwhelming. Let’s demystify this process. Goals to accomplish: Introduction to Homestead Setup Homestead on Windows 10 for all of your websites Create a Laravel 8 application SSH into Homestead and create a database Migrate database tables Verify that everything is working: able to type in domain.test in our browsers. Introduction to Homestead The first step, of course is to go to the Laravel documentation. We’ll follow it throughout this article so that if something changes
Tag: PHP Programming
Code’s way of solving problems within itself Recursion is the last topic on PHP that we’ll cover before I make the switch to Laravel. Recursion is not a PHP topic, but I’ve been asked about it so frequently that I thought we would do an article on it. It has been a fun ride and thanks for reading along on this PHP series. What is Recursion? You can get into the deep understanding of it, but for the sake of simplicity, it’s a function that calls itself from inside of the function body. In reality, it’s a way to solve
Bridging the gap between data and code I don’t know about you, but I absolutely love JSON. JSON, or JavaScript Object Notation, is a way to store and transport data. Whether we’re generating JSON objects to be sent from the server or accepting JSON objects from the client, we need to understand the JSON format. Don’t think too much into it: JSON is just a string. JSON can start with either a bracket ( [ ) or a curly brace ( { ). Either works. The object is represented with a curly brace and an ordered list starts with a
Scope surprises in PHP: The joy of debugging Scope is the variable and function visibility that a certain portion of the program has. For example, let’s say that we declare a variable inside of a function. Other functions will not have access to that variable. <?php function hello() { $name = “Dino”; echo “Hello ” . $name; // has access } function bye() { echo “Bye ” . $name; // Doesn’t have access } That variable ($name) has local scope to the function where it was created. Variables can have global scope and be accessed anywhere (not always immediately). Those
PHP’s magic methods: Invoke, toString, get, set – Class wizardry in a nutshell. We’re on the last of the built in functions/methods that PHP has to offer. We’re nowhere close to the full extent of the built in functions that PHP offers, but I think we’ve covered the most frequently used ones. In this article, we’ll look at __invoke, __toString, __get and __set methods. PHP has a few “magic methods” like __construct, __destruct, __call, __callStatic, __get, __set, __isset, __unset, __sleep, __wakeup, __serialize, __toString, __invoke, __setState, __clone, and __debuginfo. We’ve already covered the __call, __construct and __destruct magic methods. https://blog.devgenius.io/php-p101-trim-htmlspecialchars-and-call-built-in-functions-7b4f25728db9 trim(), ltrim(), rtrim() htmlspecialchars() __call()
Navigating arrays is an art, and PHP’s functions are your paintbrushes Getting close to completion. In the last article we looked at string functions and in this one we’re going to take a look at all the various and common array functions. https://www.dinocajic.com/string-functions/ trim(), ltrim() , rtrim() htmlspecialchars() __call() preg_match() filter_var() addslashes() str_replace() strlen() strtolower() strtoupper() ucfirst() strpos() , stripos() , strrpos() , strripos() Array Functions like: array_chunk(), array_diff(), array_key_exists(), array_key_first(), array_key_last(), array_map(), array_merge(), array_push(), array_sum(), asort(), arsort(), count(), in_array(), ksort(), krsort(), sort(), rsort(), shuffle(), sizeof(), is_array(), explode(), implode() Magic Methods like: __invoke(), __toString() array_chunk() If you have an array,
Strings bend to your will with PHP’s dynamic functions This article is all about string functions. These are simple built-in functions that require little to grasp. They’re conveniently named to simplify what the operations will accomplish. After we finish string functions, we’ll move on to array functions, which are just as simple. trim(), ltrim() , rtrim() htmlspecialchars() __call() preg_match() filter_var() addslashes() str_replace() strlen() strtolower() strtoupper() ucfirst() strpos(), stripos(), strrpos(), strripos() Array Functions like: array_chunk(), array_diff(), array_key_exists(), array_key_first(), array_key_last(), array_map(), array_merge(), array_push(), array_sum(), asort(), arsort(), count(), in_array(), ksort(), krsort(), sort(), rsort(), shuffle(), sizeof(), is_array(), explode(), implode() Magic Methods like: __invoke(), __toString() Addslashes() Starting off
Efficient Filtering and validation We just finished looking at preg_match and regular expressions in general. One thing that you might have quickly realized was that it’s how we used to validate whether an email was valid or not. There’s an easier way to do that now and it’s with the filter_var function. We won’t go into all of the details, but let’s explore the filter_var built-in function. trim(), ltrim() , rtrim() htmlspecialchars() __call() preg_match() filter_var() addslashes() str_replace() strlen() strtolower() strtoupper() ucfirst() strpos(), stripos(), strrpos(), strripos() Array Functions like: array_chunk(), array_diff(), array_key_exists(), array_key_first(), array_key_last(), array_map(), array_merge(), array_push(), array_sum(), asort(), arsort(), count(), in_array(), ksort(), krsort(), sort(), rsort(), shuffle(), sizeof(),
enabling precise pattern matching and text manipulation Continuing on with our built-in functions with preg_match. To review the previous functions, read P101. https://blog.devgenius.io/php-p101-trim-htmlspecialchars-and-call-built-in-functions-7b4f25728db9 trim(), ltrim() , rtrim() htmlspecialchars() __call() preg_match() filter_var() addslashes() str_replace() strlen() strtolower() strtoupper() ucfirst() strpos(), stripos(), strrpos(), strripos() Array Functions like: array_chunk(), array_diff(), array_key_exists(), array_key_first(), array_key_last(), array_map(), array_merge(), array_push(), array_sum(), asort(), arsort(), count(), in_array(), ksort(), krsort(), sort(), rsort(), shuffle(), sizeof(), is_array(), explode(), implode() Magic Methods like: __invoke(), __toString() Regex Intro I have been debating whether to even cover this one since it requires knowledge of regular expressions. We want to be as thorough as possible, so we’ll need to include some
Using trim() for input sanitization, htmlspecialchars() for security, and __call() for dynamic method handling Through the last 100 PHP articles, we’ve used all sorts of built in functions. It’s time to collect them in one place, give a couple of examples, and add any additional ones that I might have missed. You may be asking what a built in function is. It’s just a function that comes with the PHP installation. You don’t have to know where they’re at. You don’t have to instantiate an object. They’re available globally. The functions that we’re going to look at are the following: