When you're working on a PHP-focused project, the structure can differ from a typical front-end-focused project (like one with JavaScript, SCSS, and HTML). PHP-based projects are often server-side applications, and their folder structure depends on the frameworks, deployment strategy, and how the application is built.
Here's a breakdown of how a PHP-based project differs and a recommended structure:
Key Differences in PHP Projects
PHP is Server-Side:
Your code runs on the server, and the client receives the output (usually HTML, CSS, and JavaScript).
There's often no need to distinguish between src and dist, as PHP files are not "built" or "compiled"; they are interpreted directly by the server.
Focus on Backend Logic:
The project revolves around PHP scripts, templates, and logic for dynamic rendering.
Static assets like CSS, JavaScript, and images are still present but serve the front-end.
Deployment is Different:
PHP projects are typically deployed by copying the entire folder to a server or uploading files via FTP or version control.
There’s usually no "build" process (unless you're also using modern tools for static assets like JavaScript or SCSS).
Recommended Folder Structure for PHP Projects
Here’s a standard folder structure for a PHP project:
This guide outlines essential Git commands for setup, project initiation, staging, committing, branching, merging, and more.
Initial configuration involves setting a global username and email. Project setup can be achieved by creating a repository or cloning an existing one. Staging files and committing changes are crucial steps, with options to amend commits or stage all changes.
Branch management includes creating, switching, and deleting branches, while merging and rebasing ensure smooth integration of changes. Command sets for viewing status, inspecting history, and undoing changes are also provided.
Advanced commands cover sensitive data removal, squashing commits, modifying messages, managing merge conflicts, and recovering lost commits. Additionally, the guide addresses handling submodules, multiple remotes, and repository cleanup, promoting safe practices while using force-push and stash workflows.
1. Setup and Configuration
# Set a global username
git config --global user.name "Your Name"
# Set a global email
git config --global user.email "you@example.com"
# Display all Git configuration settings
git config --list
2. Starting a Project
# Initialize a new Git repository
git init
# Clone an existing repository from a URL
git clone <url>
3. Staging and Committing Changes
# Stage a specific file for commit
git add <file>
# Stage all changes in the current directory
git add .
# Commit changes with a message
git commit -m "message"
# Modify the last commit message or add more changes to it
git commit --amend
4. Branching
# List all branches
git branch
# Create a new branch
git branch <branch_name>
# Switch to a branch
git checkout <branch_name>
# Create and switch to a new branch
git checkout -b <branch_name>
# Delete a branch locally
git branch -d <branch_name>
5. Merging and Rebasing
# Merge a branch into the current branch
git merge <branch_name>
# Reapply commits on top of another branch
git rebase <branch_name>
# Abort a merge in progress
git merge --abort
# Abort a rebase in progress
git rebase --abort
6. Viewing and Inspecting
# Show the working directory and staging area status
git status
# View commit history
git log
# View a concise, graphical commit history
git log --oneline --graph
# Show details of a specific commit
git show <commit_hash>
# Show changes in the working directory (not staged)
git diff
# Show changes that are staged
git diff --staged
7. Undoing Changes
# Unstage a file
git reset <file>
# Discard all working directory changes
git reset --hard
# Move HEAD to a previous commit, keeping staged changes
git reset --soft <commit>
# Discard changes to a file
git checkout -- <file>
8. Remote Repositories
# Add a new remote repository
git remote add <name> <url>
# List remote repositories
git remote -v
# Push changes to a remote repository
git push <remote> <branch>
# Fetch and merge changes from a remote repository
git pull <remote> <branch>
# Fetch updates from a remote without merging
git fetch <remote>
9. Tagging
# Create a tag
git tag <tag_name>
# Create an annotated tag with a message
git tag -a <tag_name> -m "message"
# Push a tag to a remote
git push <remote> <tag_name>
10. Stashing
# Save changes to a stash
git stash
# Reapply the most recent stash and remove it from the stash list
git stash pop
# Reapply a stash without removing it
git stash apply
# List all stashes
git stash list
# Delete a specific stash
git stash drop
11. Advanced Commands
# Apply a specific commit from another branch
git cherry-pick <commit_hash>
# Binary search to find the commit that introduced a bug
git bisect
# Show a log of all references (HEAD changes)
git reflog
# Show who changed each line in a file
git blame <file>
A good tool to test Ubuntu server performance is called "Sysbench." Sysbench is a versatile benchmarking tool that allows you to assess various aspects of system performance, including CPU, memory, disk I/O, and database performance.
Here's how you can install and use Sysbench on your Ubuntu server:
Installation:
You can install Sysbench using the following command in the terminal:
sudo apt-get install sysbench Usage: Once installed, you can use Sysbench to perform various types of benchmarks. Here are some common examples:
CPU Benchmark: sysbench cpu --threads=2 run
Memory Benchmark: sysbench memory --memory-block-size=1K --memory-total-size=10G --threads=1 run