The PHP Plugin


As of CodeLite 7.0, PHP support in CodeLite has been extended to provide a fully workable PHP environment for editing and building a PHP application or a simple website.

The PHP plugin supports (but is not limited to) the following:

  • Code Completion
  • Debugging capabilities via XDebug
  • Syntax checking
  • Simplified project management
  • Class wizard
  • Remote synchronizing over SFTP
  • Refactoring

Concepts


The Workspace file


Unlike a standard workspace in CodeLite, a PHP workspace uses its own tab in the IDE, named "PHP" in the "Workspace View" pane on the left side.
CodeLite's PHP workspace contains the following information:

  • List of project files (will be discussed later)
  • Metadata (workspace file format version and other info needed by CodeLite)

Only one workspace can be loaded at a time within CodeLite; however, each workspace may contain multiple projects.

Each workspace is represented on the file system as a single file with the extension .workspace

The Project files


Each PHP project corresponds to a real directory on the file system (i.e. there are no Virtual Directories as there are with standard C++ CodeLite projects).

A project may contain subfolders, each corresponding to a dir in the matching position on the file system. However you don't have to include every real dir; you may define filters to define which dirs and files you wish to view (e.g. .git, .svn etc) in the project settings.

Projects can't be nested: a project tree can't contain another project.

Getting Started


Create your first workspace

Creating a PHP workspace is done by clicking on the New Workspace button in the Welcome Page (or from the menu: File -> New -> New Workspace )

  • Click on the New Workspace button.
  • Select PHP as the workspace type (at the time of writing this, CodeLite supports two types of workspace: C++ and PHP)
  • Fill the workspace details
    • The workspace name - give your workspace a meaningful name
    • Select the workspace location (i.e. where should CodeLite create the workspace file)
    • Optionally: you may choose to create the workspace under a new folder
  • Now that the workspace file has been created. We can start adding projects to it. We do this, by right clicking on the workspace icon and selecting the menu entry Create a new project
  • Follow the new project wizard. At the moment, CodeLite offers to create 2 types of project: an empty project or a project from an existing source files. In this short tutorial, I have chosen the option to create an empty project.
  • Now that you have your wrokspace and project setup, lets create a simple "Hello World" example:
    • Right click on the project and select New Class
  • Click OK and edit the MyClass by adding a simple HelloWorld
  • Run the project by hitting Ctrl-F5 or Right clicking the project and selecting Run Project

Syntax checking


CodeLite has built-in intergration for PHP_CodeSniffer, PHPMD and basic php lint.

Theas tools look for code style violations, code design issue and basic syntax errors. When an issue is detected a marker will be placed to the left of the affected line, hover the marker to view a description of the issue.

Setup


From the main menu select Plugins->PHP Linter->Options.
Under the general tab you can enable automatic linting on file load and file save.

Under the Code Sniffer tab you need to specefy the path to the phpcs phar file. Configuration of phpcs should be done by creating a phpcs.xml rule file and placing it in your projects root folder.

The Mess Detector allows you to point to the phpmd phar file and an optional rule set xml file.

You can use an online standard generator to generate the XML rule files.

Refactoring


CodeLite relies on an external tool for providing PHP refactoring (rename variables, class properties etc)
To enable refactoring, follow these steps:

You are now able to perform code refactoring (like renaming variables, moving selected code in to a separate method) from the right click menu or from the project level context menu

Edit - History - Print - Recent Changes - Search
Page last modified on July 04, 2017, at 08:49 PM