Monday, December 23

Tag: php

Explain Laravel schema ?
Laravel

Explain Laravel schema ?

  The Laravel schema explained The Laravel schema is used because it provides database agnostic support for creating and manipulating tables across all the Laravel supported database systems. It has a unified API across all these systems. Various manipulations are done in a database table like- creating and dropping tables, adding columns, changing columns, renaming columns, dropping columns, checking existence, adding indexes, etc. A schema is basically a representation of a plan or theory in the form of an outline or a model. In Laravel technology, your tables are exported as a Laravel schema to be used in migrations. For example, the syntax for creating a new database table is given below- Schema:: create function is used to create a new table in Laravel 5 Schema::create (...
PHP-FPM tuning: Using ‘pm static’ for Max Performance
PHP

PHP-FPM tuning: Using ‘pm static’ for Max Performance

Let's take a very quick look at how best to set up PHP-FPM for high throughput, low latency, and a more stable use of CPU and memory. By default, most setups have PHP-FPM’s PM (process manager) string set to dynamic and there’s also the common advice to use ondemand if you suffer from available memory issues. However, let's compare the two management options based on php.net’s documentation and also compare my favorite for high traffic setup --- static pm: pm = dynamic: the number of child processes is set dynamically based on the following directives: pm.max_children, pm.start_servers, pm.min_spare_servers, pm.max_spare_servers. pm = ondemand: the processes spawn on demand when requested, as opposed to dynamic, where pm.start_servers are started when the service is started. pm = stat...
23 Development Tools for Boosting Website Performance
PHP

23 Development Tools for Boosting Website Performance

When dealing with performance, it's hard to remember all the tools that might help you out during development. For that purpose, we've compiled a list of 23 performance tools for your reference. Some you'll have heard of, others probably not. Some have been covered in detail in our performance month, others are yet to be covered future articles; but all are very useful and should be part of your arsenal. Client-side Performance Tools 1. Test your Mobile Speed with Google Google’s Test My Site is an online tool offered by Google and powered by the popular website performance tool WebPageTest.org. You can either visualize your report on site or have it emailed to you via your email address. The tool gives you your website loading time (or Speed Index) calculated using a Chrome browser on...
Case Study: Optimizing CommonMark Markdown Parser with Blackfire.io
PHP

Case Study: Optimizing CommonMark Markdown Parser with Blackfire.io

As you may know, I am the author and maintainer of the PHP League's CommonMark Markdown parser. This project has three primary goals: fully support the entire CommonMark spec match the behavior of the JS reference implementation be well-written and super-extensible so that others can add their own functionality. This last goal is perhaps the most challenging, especially from a performance perspective. Other popular Markdown parsers are built using single classes with massive regex functions. As you can see from this benchmark, it makes them lightning fast: Library Avg. Parse Time File/Class Count Parsedown 1.6.0 2 ms 1 PHP Markdown 1.5.0 4 ms 4 PHP Markdown Extra 1.5.0 7 ms 6 CommonMark 0.12.0 46 ms 117 Unfortunately, because of the tightly-coupled design and overall architecture, it's dif...
PHP

How to Optimize Docker-based CI Runners with Shared Package Caches

At Unleashed Technologies we use Gitlab CI with Docker runners for our continuous integration testing. We've put significant effort into speeding up the build execution speeds. One of the optimizations we made was to share a cache volume across all the CI jobs, allowing them to share files like package download caches. Source: Sitepoint
PHP vs Python in 2018?
PHP

PHP vs Python in 2018?

One question I get often, is which programming language should you learn? … I’ve been getting this question for years! Things change in the programming world, languages come and go. But the good news is that the basics, the core concepts and techniques, are 90-95% the same in all the modern programming languages: JavaScript Python Java for web apps or Java for Andriod PHP C# Swift C++ C …. What that means, is that your programming language choice, isn’t nearly as critical as you’d think. Why? Well, once you know one programming language, it is easy as apple pie to switch to another! How to choose between PHP and Python? The key to choosing a language comes down to two things: market viability of the programming language and what KIND of programming you want to do....
How to Optimize SQL Queries for Faster Sites
PHP

How to Optimize SQL Queries for Faster Sites

You know that a fast site == happier users, improved ranking from Google, and increased conversions. Maybe you even think your WordPress site is as fast as it can be: you've looked at site performance, from the best practices of setting up a server, to troubleshooting slow code, and offloading your images to a CDN, but is that everything? With dynamic, database-driven websites like WordPress, you might still have one problem on your hands: database queries slowing down your site. In this post, I’ll take you through how to identify the queries causing bottlenecks, how to understand the problems with them, along with quick fixes and other approaches to speed things up. I’ll be using an actual query we recently tackled that was slowing things down on the customer portal of deliciousbrains.c...
PHP

How to Read Big Files with PHP (Without Killing Your Server)

It’s not often that we, as PHP developers, need to worry about memory management. The PHP engine does a stellar job of cleaning up after us, and the web server model of short-lived execution contexts means even the sloppiest code has no long-lasting effects. There are rare times when we may need to step outside of this comfortable boundary --- like when we're trying to run Composer for a large project on the smallest VPS we can create, or when we need to read large files on an equally small server. It’s the latter problem we'll look at in this tutorial. The code for this tutorial can be found on GitHub. Measuring Success The only way to be sure we’re making any improvement to our code is to measure a bad situation and then compare that measurement to another after we’ve applied our fi...
PHP

Your First PHP Code

The following is a short extract from our new book, PHP & MySQL: Novice to Ninja, 6th Edition, written by Tom Butler and Kevin Yank. It's the ultimate beginner's guide to PHP. SitePoint Premium members get access with their membership, or you can buy a copy in stores worldwide. Now that you have your virtual server up and running, it’s time to write your first PHP script. PHP is a server-side language. This concept may be a little difficult to grasp, especially if you’ve only ever designed websites using client-side languages like HTML, CSS, and JavaScript. A server-side language is similar to JavaScript in that it allows you to embed little programs (scripts) into the HTML code of a web page. When executed, these programs give you greater control over what appears in the browser win...
PHP

What is PHP 7?

PHP 7 - a revolution in the field of web development. This is the most important change for PHP since the release of PHP 5 in 2004, bringing explosive performance improvements, drastically reduced memory consumption, and a host of brand-new language features to make your apps soar. You also be wondering why PHP named its latest release PHP 7 and not PHP 6. Reason behind it is that, many of the PHP 6 releases were already implemented in PHP 5.3 and later, there was not really a proper reason just to change the name. What I am trying to say here is that we haven’t missed anything. Just to avoid the confusion with a dead project, PHP's latest release was named to PHP 7.
PHP

What does phpinfo () do?

phpinfo () is used to check configuration settings and for available predefined variables on a given system. phpinfo () is also a valuable debugging tool as it contains all EGPCS (Environment, GET, POST, Cookie, Server)
PHP

What is the PHP?

PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
Learning PHP more Easily by Learning Python … what!?
PHP

Learning PHP more Easily by Learning Python … what!?

PHP is probably the best web app development language out there today for a bunch of reason technical, and market oriented. But it’s not the only language out there and it doesn’t have a monopoly of good programming. Comparing Programming Languages An important lessons that my 20+ years of programming experience has taught me, is that one of the best ways to learn one programming language, is to learn another! By learning different programming languages, you will start to gain deeper insights about your first programming language. Here is the key point, most modern programming languages share about 98% of the same principles and language constructs. That said, each language has their own subtle take on how they do things. So for example, PHP creates functions with this code: function...
Python 3 Course of College and University
PHP

Python 3 Course of College and University

I am excited to announce our upcoming Python course: Powerful Python 3. A beginners course covering Python 3, students go from an absolute neophyte, to having a working knowledge of object oriented Python.  Course is based on Python 3.6. StudioWeb course details: In addition to a set of comprehensive and engaging videos, Power Python 3 will include quizzing, code challenges, and gamification that is provided by the StudioWeb app. Your students will learn Python easily, and they will have fun too! Each video lesson is supported by 4-5 quiz questions, that are made up of both code challenges and multiple choice questions. All our courses leverage the recursive spiral teaching method that helps us to achieve great outcomes with students. Professor’s Dream: From a professor’s perspecti...
Open Ended Lesson Plans and Teaching Code
PHP

Open Ended Lesson Plans and Teaching Code

After nearly 7 years of working with schools, it seems clear to me that the best way to teach code, is with an open ended lesson plan. Here’s why: Learners will learn at different speeds Different schools have different schedules Rigid lesson plans will inventively break Overly rigid lesson plans can easily be derailed … I hear about it all the time. Once that happens, teachers are scrambling to get things back on track. The other approach is to use a flexible lesson plan that allows for variability in the classroom: Student misses a few days. Student is talented and moving fast Student is struggling and needs more time School gets cancelled a few days for whatever reasons … A curriculum designed for reality Instead of a set of highly structured lesson plans that can b...