nanodano's blog

Advertisement

Advertisement

How to Setup Drupal for Local Development with Just PHP

With older versions of Drupal you could not run Drupal without Apache or Nginx to perform the URL rewrites needed to use the application with clean URLs.

New versions of Drupal (8+) come with a .ht.router.php file that is specifically used to run local development instances with just the built-in PHP web server. No Apache, no Wamp, no Mamp, no Xampp. Just the built-in PHP server.

In addition, you don't have to use MySQL an setup a separate database. Drupal supports SQLite3 so can completely skip any MySQL setup.

This means you can run a local Drupal development environment with nothing but PHP.

  • No Apache
  • No MySQL
  • No Wamp,Xampp,Mamp
  • Just PHP

Following the method in this guide works on Windows, Mac, and Linux equally.

Run JavaScript After DOM is Fully Loaded

Introduction

When writing JavaScript for a web browser, there are times when you want the page to fully load before the code is executed. This is particularly true if your JavaScript manipulates or utilized the HTML DOM. Your JavaScript will fail if it tries to reference an element that has not yet been loaded. This example will show you how to defer code from being executed until the web page has fully loaded.

PHP Composer Basics

Composer is a command-line tool for managing dependencies in PHP projects. In this guide we will look at how to install Composer and use it to add and install some project dependencies as well as how to create your own local package and use it within an application.

Working with Git Repositories in Python

The GitPython project allows you to work in Python with Git repositories. In this guide we'll look at some basic operations like:

  • Initializing a repo
  • Cloning a repo
  • Adding and committing
  • Pushing and pulling with remotes
  • Checking for changes
  • Getting a diff
  • Listing and switching branches

For full documentation, see https://gitpython.readthedocs.io/. The source code is available at https://github.com/gitpython-developers/GitPython.

Python FTP Client Tutorial

FTP or File Transfer Protocol is a common way to transfer files. For FTP, Python has a built in package called ftplib.

There is also a Secure File Transfer Protocol (SFTP) that uses SSH to encrypt the communication. We will focus just on traditional FTP in this guide. For SFTP you can check out the Paramiko package.

In this guide, we will look at some basic operations like:

  • Connect and login to an FTP server
  • List directories and files
  • Upload and download files

Note these examples are all using Python 3.

Read and Send Email with Python

Python 3 has built-in libraries for IMAP, POP3, and SMTP. We will focus on learning how to send mail with SMTP and read/manage email with IMAP. We will also look at how to send an SMS text message using email.

If you need your own email hosting, check out Interserver.net hosting where you can host unlimited emails for unlimited domains as cheap as $4/month. You could also set up your own SMTP server on a VPS, but that is a hassle.

Python MySQL Tutorial

MySQL is an ubiquitous database server. Many hosts, like Interserver.net offer unlimited MySQL databases with a $4/month plan. With their hosting, you can also setup as many PHP, Python, Ruby, or Node.js apps.

There are a few libraries available, but the one I'm focusing on is PyMySQL, a pure Python implementation. This version is the easiest to install with the least amount of dependencies and most portable.

You could use an ORM like SQLAlchemy or Django. Those options are good if you need to easily switch between MySQL and another database like SQLite. Here, we will focus only on MySQL and assume this is the only database being used.

If you're interested in learning how to setup a Python web app on Interserver, it is really easy using cPanel. Check out my tutorial Setup Python WSGI apps on cPanel (Flask/Django).

Advertisement

Advertisement