Managing assets with Laravel 4

Generally assets are stored in your public directory, right? They are public, so anyone can get access to them. But nowadays the performance is a very important factor when deploying a new app. I strongly recommend you to minify and cache your assets, like CSS files, Javascript files and Images.

If you are using 11 javascript files in your app you don’t have to make 11 requests on the server, one per JS files. You can easily join all files and minify them, so you will have just one minified file. This is easy to do using Laravel 4! I’ve found four Laravel 4 assets managers:

We will work with codesleeve/asset-pipeline package. It’s easy to use and simple to understand.

Continue reading Managing assets with Laravel 4

Solve the problem. Just it!

These days I’m thinking about productivity and the use of PHP frameworks. I’ve read some posts about framework X or Y, defending a framework instead of another one.

I know people that use a framework like Zend Framework to develop a simple website just to say they’re using it, and not an “easy” framework. I think you must to solve the problem, not create another one. You have to use best practices but first you have to solve the problem, nothing more.

You don’t have to use a hard-to-learn framework just to say your friends you know about it. You can do amazing things with easy-to-learn frameworks, like Code Igniter, CakePHP, Laravel or Slim. You can do better even with pure PHP if you want, but you have to concern about productivity (and security of course).

Continue reading Solve the problem. Just it!

Testing your Packagist/Composer package locally

Hello again! It’s my second post today! I’m electric!

I am developing a project that uses a package I’m developing too. So, it is a real time test project. I find a new way to do something and write it inside my package and uses that.

But sometimes this is a boring work. I am sharing my package in the Packagist website using Composer, and everything I change I have to commit, push to GitHub and update my project with Composer, to get the new code I’ve wrote. That’s a very very bad idea.

Yesterday I was talking with my friend @diegoholiveira about to test the package locally and we’ve found a easy solution. You can change the package you are developing and use that in the project that uses it. We were trying to find an easy way to do that using Composer, but the solution was easier than that. Just use symbolic links.

Continue reading Testing your Packagist/Composer package locally

Creating your first Composer/Packagist package

Hi everybody! Today I’ll write about how you can contribute with PHP community creating packages (or updating your’s) using Composer and Packagist. First, if you’re a PHP developer and don’t know yet what is Composer, take a look on the post Why you should use Composer and how to start using it to get more information about.

Using Composer

Composer is a package manager for PHP. You can use packages the community developed and you can contribute with your packages too. Here I’ll show how to create a project/package, install Composer inside it and send to Packagist, where others developers can use it inside their projects.

Continue reading Creating your first Composer/Packagist package

Why you should use Composer and how to start using it

Hello!

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

Why you should use a PHP Framework and why I’m using Laravel

Hello everyone!

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