As a developer, you may familiar with this concept .DRY. Which means don't reinvent the wheel?
All we do to make our life much easier because this will increase productivity which converts at the end to money
Codeigniter Phpstorm
So I thought to share simple tips from my experience that will help you in Codeigniter projects and makes your life easier
1- Use HMVC approach
Use HMVC approach. If you don't know what is HMVC. Modular HMVC is: Hierarchy of multiple. Auto complete code for codeigniter using phpstorm 06 min. Creating custom helper to reduce the code 13 min. Creating the database for site 18 min. Creating the relations using dataDrid. Creating Categories 30 min.
If you don't know what is HMVC
A. Modular HMVC is: Hierarchy of multiple MVC triads
Separate your code as modules makes your code clean, easy to maintain and gives you the chance to reusing code many times without effort to mention
The most popular HMVC wiredesignz is my favorite tool.
Codeigniter modular application is the way to go because every module handles a specific logic, so collect similar controllers and models ,libraries in one module let you less confusing and after a while, you could remember what you did in this module, then it will be easy to copy module with all its own code.
2- Use Base model
If you don't know what base model you should know about it is, basically it is a parent model class which provides the most popular functions that every developer needs for every project
As an example, every project needs CRUD functionality (create-read-update-delete).
So rather than write those functions more and more, you just call one inherited function with Short syntax and it will do the magic.
So if you have a ton of models this will increase your productivity and you would notice that .
also, it will make your model thin because you will focus on the project specific logic.
I suggest to use this Codeigniter base model, it is simple, light and you can customize for your tasks
3- Build your own helper
Usually, In many projects, there were something repeated and you were forgetting to change or may by lazy like me to change.
Something like truncate functions which count and cut number of words
Or a function to create thumbnails for images to fit website design or date converter function.
You should collect those functions and build your own helper to use in all projects. This habit will make you code cleaning and fewer efforts.
4- Use a better editor Fashion angels fashion design portfolio.
My best choice is Phpstorm ,I love this editor, it has all tool you need as a PHP developer, you can manage FTP very well ,you can manage VCS with GIT repository without worried about commands ,I have already make a git course to this subject and it will complete as soon as possible
Also, you can make your shortcuts for repetitive codes to reduce coding time and save these settings anywhere to share between many computers.
As example many time I use
to show what query run behind the scene this helps me a lot to fix database query errors so I thought to make a shortcut for this like this (lst) ,So whenever I write these three characters the Phpstorm complete the remains. Webex calling microsoft teams.
Another thing you may notice, that Phpstorm has many plugins to support many things like composer and also PHP frameworks, content management systems, but
Unfortunately, Codeigniter not being one of them which means you cannot take advantage of auto-completion.
Although supporting Codeigniter in Phpstorm not found yet, but you will find PHP storm Codeigniter helper which will help you a lot with auto complete in Codeigniter.
After downloading this helper you can copy the code and put in parent class which you inherited from in all your project classes and it will give you decent autocompletion support.
5- Google it, be smarter.
In PHP world you are not alone, in Codeigniter world the same, always there was the same problem that someone ran into beforehand.
So don't reinvent the wheel, just take your time to search, look at other's code this will help you twice, to improve your coding skills and to increase your productivity.
Sometimes you will find the solution in Codeigniter forum, sometimes in Codeigniter blogs like Webeasystep :) or maybe in PHP community, then your role to convert it to a code igniter library or helper to make our community rich.
These my quick tips to share and I hope to help you and will be very happy with your shares
Leave a Reply
Your email address will not be published.CodeIgniter 4 requires PHP version 7.2 or higher. The earlier version requires a minimum PHP 5.3 version or higher.
There is now a public directory like in other frameworks. You can now separate the application from the resources (like CSS, JS, files.).
It is much more difficult for attackers.
In this tutorial, I show how you can install the Codeigniter 4 project on Windows and Mac.
Contents
1. Enable extensions
- Open
php.ini
file to enableintl
andmbstring
extension. - Search extension in the file.
OR
Phpstorm Codeigniter Library
- Remove semicolon (;) if exists to enable the extension.
- Restart the server.
2. Manual Installation
- Download CodeIgniter 4 zip file from here.
- Copy in the
htdocs/
folder and extract it. - Rename the folder (e.g. codeigniter4).
3. Using composer
Config Codeigniter Phpstorm
- Navigate to
htdocs/
using Command Prompt if you are on Windows and use the terminal if you are on Mac. - Run the following command –
- Replace project-root with your project name like – codeigniter4.
- If you are getting the following message on the Command prompt while running –
- It means
intl
extension is not been enabled. - To enable the extension follow the step 1.
- Re-run the
composer create-project codeigniter4/appstarter project-root
. - A new codeigniter4 folder will be created.
4. Run
- Run the project
public/
folder.
- On Mac in case, you are not viewing the above page instead following page display –
- Then need to change the permission of the
writable
folder. - Navigate to the project directory using the terminal and execute the following command and refresh the page.
Local Development Server
- You can also run the project by starting a local development server.
- Run the following command in the Command Prompt if you are on Windows or on the terminal if you are on Mac.
- Development URL display after starting.
- Run – http://localhost:8080/ in the browser.
5. Conclusion
You can either install it using a composer or manually. Before installing make sure that the PHP version is 7.2 or higher.
If you found this tutorial helpful then don't forget to share.