One of the most big changes happening in PHP world is the Composer. I’m shure you heard about it but maybe you don’t know why you should use it and how much it is good for you and your projects.
What is Composer?
When you need some specific code in PHP you can go to PHP Classes and search for what you need. For example, you need a class to connect to your Twitter account and get the last updates in your timeline. Ok, you’ll find it easy. And what you have to do after? You download the classe and copy to some place inside your project, and call it including or requiring it inside your PHP code, right?
Well, you can use Pear to. You must install it on your server and install some components that you can use like a package manager. This work too but nothing is installed inside your project structure, but in your machine.
Ok. Composer came to solve all this questions. Together with Composer we have some rules, making all PHP project with the same structure, using namespaces, the same code style, etc. This simplifies when you have to include some third-party code or project. This rules you can find at PHP Fig (PHP Framework Interop Group). I really suggest you to take a look at phptherightway.com. There you’ll find a lot of information to made you a good PHP developer using what we have of better in PHP world.
Continue reading Why you should use Composer and how to start using it
Today I had to update a project that was developed using WordPress and PHP 5.3. Today I have PHP 5.4 installed on my machine and this newer version abandoned some old features, and you have some Fatal errors like Call-time pass-by-reference has been removed. The solution was go back to PHP 5.3 and do the updates on my the project, because the production server is with PHP 5.3 too.
The cleaner solution is using Vagrant, that allow you install only what you want for a specific project, leaving your machine cleaner. But was not my case at the moment.
I’ve used macports to install PHP in my machine. I think macports is a very good way to organize all sources in the same place. More information you can find here.
You can install PHP 5.3 and 5.4 in the same machine and decide what you’ll use just updating your Apache httpd.conf file.
Continue reading Working with multiple PHP versions on MAC OS-X
Use or not to use a PHP Framework on your new projects? Here I’ll talk about my personal opinion about that and I wish help you.
First, I have a simple concept about languages and respectives frameworks: a framework must make the development simpler. Every software has a single purpose: work! This is the main goal of every project, do that to simplify the life of someone.
Talking about PHP, it is a very simple language. It was projected to be simple and fast. If you want a language complicated or filled of dependencies, PHP is not your best choice.
PHP has the power to do a lot of things in a single line, so, if your framework of choice do the same thing in 3 or 4 lines, use the native PHP way. But you’ll ask me your framework do the same job but much better, using OO, or with beautiful code. Remember you must do the thing and make your project work. Of course the OO programming is the recommended way and you must use it, to make you like easier.
What I want to say is you should use the simpler way, to make the development faster and better. Choose a framework that help you to do the job faster, and use PHP for that. Exists some frameworks that you must learn another language almost. For me a framework must be easy to learn and with minutes you will be developing using it and make money.
Continue reading Why you should use a PHP Framework and why I’m using Laravel
Laravel is an awesome PHP framework created by Taylor Otwell. Actually, it is on the third version and it is one of the great PHP frameworks we have today.
As a lot of frameworks, we have to create our own Apache Virtual Host to point to the public dir to improve security and only allow access to really public files.
Some people asked me to create a blog post about how to deploy Laravel application to a shared host, like my post about how to Deploying Zend Framework applications on a shared host.
Laravel file structure
A basic Laravel application has the same file structure:
- application/: your app files, like controllers, routes, models, views, tasks, etc
- bundles/: the bundle’s files you’ve installed for your app
- laravel/: the Laravel’s files
- public/: your public files
- storage/: files about cache, session, logs, etc
- artisan: the Laravel command line file
- licence.txt: licence file
- paths.php: file with paths information
- readme.md: just a readme file with Laravel instructions
Continue reading Deploying Laravel applications on a shared host
Let’s continue with our WordPress series. Today I’ll write about the main files in a WordPress theme.
Above we have some files that are basic for your new theme:
This file is the root file, the home page. When you open your WordPress website it’ll get this file content. Is can also be renamed to home.php, not problem. WordPress will understand that.
As we saw in the first post about WordPress themes, this is the file you’ll have your header content. Things like navigation, logo, users welcome messages and more, you’ll find in this file.
Continue reading Creating your first WordPress theme – Part 3 – Important files
As I said, this is our second post about Themes in WordPress. Today I’ll talk about:
- How to create page templates
- How to retrieve posts
If you want you can read the first post about WordPress themes.
Continue reading Creating your first WordPress theme – Part 2
Continuing with our first WordPress site, now we’ll understand how WordPress allow you to customize themes.
If you didn’t read the first post about WordPress Thinking the WordPress Way – First Steps and want to learn how WordPress works, take a look.
Our new theme will called grossi. Every theme you create will be stored in the /wp-content/themes/grossi.
First, you need to create the grossi folder and put a style.css file inside it with some content. This file is used by WordPress to see your new theme. After that you’ll can activate your new theme in your Administration Panel.
Continue reading Creating your first WordPress theme – Part 1
I work with PHP since 8 years and I never took a look on WordPress. In the start of this year a customer requires me to develop his next website, but using the WordPress. So I had to search some tutorials on the Internet and join informations to make my own way to think using WordPress.
In this first post I’ll explain how to THINK in the WordPress way, the files you need to customize, create and how to get posts in yours next website pages.
How WordPress works
The first question I had is how to imagine a new website in the WordPress way. It’s easy, because it has only 2 ways of save data: Posts and Pages.
It’s simple to understand. Let’s take a sample website content to explain better:
- About Us
Continue reading Thinking the WordPress Way – First Steps
Another quick tip. To start a new Zend Framework project, the easiest way is using Zend_Tool for that. Please, install first the Zend_Tool follow this link at Zend Framework documentation page.
Creating new project
Let’s starting using the command line and creating a new ZF project.
zf create project my_project_name
Now, get in the project folder and enable Zend_Layout support:
zf enable layout
Continue reading Creating new Zend Framework project using Zend_Tool
Here I am again.
Today I have a quick tip for beginners using Zend Framework.
Do not insert pre and post code (for database) in your Controller. The
Zend_Db_Table_Row is for that.
Lets create our
DatabaseTable class for Posts:
* Located in .../models/DbTable/Posts.php
class Posts extends Zend\_Db\_Table_Abstract
protected $_primary = 'id';
protected $_name = 'posts';
protected $_rowClass = 'Post'; // here we linked the Post class above
Continue reading Pre and post database operations with Zend Framework using Zend_Db_Table_Row