How to create a PHP project with IntelliJ Idea 9? - php

I can't find how to create PHP project with IntelliJ Idea 9. It only offers "Java module" and "Maven module" to choose when creating a project. PHP plugin is installed, but how to employ it?

UPDATE: Web module type is available since IntelliJ IDEA Ultimate 11. Use Web module type to create PHP projects in IDEA.
Old answer prior to IDEA 11:
It's a known limitation, IDEA doesn't support creating project without any module type like PhpStorm/WebStorm products since it supports many languages and technologies. But it also doesn't have a special module type for PHP or web projects yet.
At the moment you should use dummy Java module, you can omit creation of the src directory and all the other Java specific stuff, but you have to choose Java module type for your PHP/web projects.
This may change in the future IDEA versions as we plan to support opening PhpStorm/WebStorm projects in IDEA and vice versa.
There is also a request to support web modules in IntelliJ IDEA that you can watch for progress.

I'm on IDEA 11.0.2 and I still have to create a barebones Foo.java file in the non-Java module I want to create. So frustrating. Meaning that if I want to create a module for my JavaScript project or for my PHP project I need to put that file in there and do New module...from existing sources, then delete the Foo.java.
There's got to be a better way!

Related

Node js/Express to replace LAMP

I need help from you NodeJS ninjas. I am starting to learn it, after doing a good amount of LAMP stuff. I have written several systems in Apache/PHP/MySQL for a small corporate intranet (including things like a ticket system, employee scheduling, production reports, financial reports, etc).
So, in LAMP world, I start the Apache and MySQL engine. Then people go to their browsers, type the server IP and browse the different systems I've written for them based on the folder in htdocs.
I am trying to think what the equivalent would be in a set up with NodeJS, Express using the MVC model (something I am also new to). Two main questions:
Since I have several systems (employee scheduling, financial
reports, etc), would each one of these have their own middleware for managing, with their middleware rules and all that? or would they all run under just a main thread? (load balancing is another thing that came up).
What would the folder layout be? XAMPP had the htdocs folder and the folder structure was whatever I wanted.
From what I've seen in most tutorials, an option for a folder layout is:
-app
-- controllers
-- models
-- routes
-- views
-config
-- env
-node_modules
-public (I imagine the systems I implement would be on here?)
-server.js
Thank you for your help, I am still a complete noob, but I am excited to get into this.
I come from LAMP stack word and moved to nodeJS 2 years ago. A lot changed since then.
Things you need to know for nodeJS vs PHP :
nodeJS runs under google's JavaScript V8 engine.
nodeJS is ingle-threaded. PHP is multi-thread. That means any modification to a global variable, if there's any, is seen by all the connected users.
nodeJS with express alone is not MVC since MVC is a architectural pattern. You can if you want create folders to define a MVC pattern or hMVC pattern (depending on your needs). A bigger frameworks called SAILS does native MVC for you.
to start a nodeJS project, you have to cli node yourApp.js. That said, there is a better way to start a project using a script placed inside package.json managed by npm or using other npm package such as nodemon. There is no specific folder to start a project like PHP since PHP is managed by Apache and Apache is configured to have a specific folder for html docs.
Other things to add :
Javascript uses EcmaScript as scripting language. The version 6 of ES was finalised in summer 2015, and all browsers still doesn't native take it in charge. Since nodejs uses google's v8 engine, it's still based on ES5.1 or experimental ES6 with --hamrony flag calling node in cli. Since node5 many ES6 features are implemented but still not all are.
NodeJS is asynchronous, and async call are HARD to learn when you come from php word. You will need a lot of practices. I suggest you go read module pattern and revealing pattern.
I hope I have answered you'r questions

Using PHP, how can I determine which CMS or framework is used?

Using PHP, can I find out which CMS or framework is used on a particular website. Eg Wordpress, Magento or Codigniter, Laravel.
I've tried this approach: http://dailyblogging.org/internet/detect-cms-and-scripts-of-websites/
This is what I actually want, but in code form, not as an online service: http://onlinewebtool.com/cmsdetector.php This should be a PHP script that does not run as an online service.
What will it take to do this, or at least give me a hint?
Update 2018
Github repo moved:
https://github.com/AliasIO/Wappalyzer/blob/master/src/apps.json
There is a Chrome extension called Wappalyzer.
You can see some regexp which are included in the wappalyzer project for detecting servers, cms and frameworks.
Maybe you can include this and write a php script that uses this:
https://github.com/ElbertF/Wappalyzer/blob/master/share/apps.json
For Drupal, view source
And if you find
/sites/all
/sites/
For including image/javascript/css, its Drupal based site.
Same way, if you find wp_content, its wordpress.
For MVC ftameworks, its difficult to determine as url routing is same for all.

How to set up a new library in NetBeans PHP project?

I'm a newbie to NetBeans IDE (version 8.0.1 for PHP) and I'm trying to create a library containing the functions I'd like to use frequently (like DB connection, string manipulation and so on) so I'd be able to include it to my further projects.
The project is connected to GitHub repository and remote SFTP folder (if those notes are important).
As was described in the answer to the question Creating/accessing libraries in netbeans I tried to pick Tools ->Libraries menu item. But the button new library in the opening window is inactive.
I have no libraries in the Project navigation window as well. So I'm definitely doing something wrong.
Cound anyone point me why I'm not able to create a new library?
UPDATE TO THE QUESTION: What exactly I probably need is a tool to attach php file with library functions and classes to the project so I could just include it to the index.php file (or anyone needed this library).

Module-based projects: when to use them or not use them

I'm starting to familiarize myself with using the module-based architecture for zend framework projects. My real reason behind being interested in the module architecture is to be able to take a module from one project and just drop it into another project. Maybe I'm not getting it right..
But what I'm noticing right off the bat is that controllers within each module cannot have the same name as any other controller in the main application (or in any other module, though I haven't tested this). This leads me to think that modules are not really independent self-contained units, so I wonder how this affects their ease of distribution from one project to another.
The other issue is what if I were to take a module and drop it into another project. Do I have to update the .zfproject.xml manually? and wouldn't that be a bit too cumbersome to be done manually?
Maybe I'm not clear on how modules should be used in zend, so I'd like to know when you decide it's best to use them, and when do you decide not to use them, or do you use them all the time, or do you never use them?
I always used module based architecture so far in my projects, because I like to separate concepts. For example I have always an ADMIN module whose classes and controllers dont mix with the rest of the application. Using modules you can reuse modules for other applications, for example if you create a BLOG module.
The names of your controllers will be something like Admin_IndexController for the admin module even if the file is named IndexController.php.
Another concept that is nice and help you reuse resources is the plugins. Use them for authentication or to check validity of the requests.
You need to setup namespaces for your modules so that they are easily moved into a new project without renaming.
If you are using Zend Tool then you will have to edit the zfproject.xml. I haven't spent a lot of time using this so I'm not sure if there is another way without manually editing.

ActiveScaffold for PHP

Ruby on Rails has a bunch of plugins which extend the normal scaffolding:
Lipsiadmin
Hobo
Streamlined
ActiveScaffold
Does the PHP community have anything similar? phpmyadmin is great, but it doesn't have any way to control the presentation of the data. You always get all of the data in its presentation format. These Rails frameworks are a little more user friendly.
Edit: My original question was not very clear. I'm not looking to compare PHP and Rails. I'm also not looking for an all purpose general framework. I'm looking for something just like the four pieces of software I listed above, but written in PHP. The admin software I listed above generates a crud interface for you based on your configuration. The configuration includes which tables you'd like to show, what operations you can do to the table, and who can see the information. The software does the rest, from writing the SQL to processing the request to generating the interface.
I would look at Zend, CakePHP, CodeIgniter or Kohana. See if they have an addon or plugin that can do it.
The problem with the four pieces of software you listed is that they extend Rails. When you say "PHP," there is nothing to extend in the same sense. (I really doubt you want a PHP module that does this.) You don't need a PHP addon, you need a [framework] addon.
Any of the frameworks I or Jonathan listed are similar to Rails. Kohana in particular has an addon module called Auto Modeler that may do what you need.
have you looked at pear: http://pear.php.net/
It's important to stress the difference between a language and a framework here. PHP is not itself a framework with modules. PHP is a language, like C or Python.
There are several website frameworks that have been written in PHP. The most popular would probably be Drupal though there are several that I've looked at over the last year that seem similarly capable:
CakePHP
CodeIgniter
Joomla!
Symfony
Zend
PhpMyAdmin is not a module or a framework. It is a separate, stand-alone web application for database administration, written in PHP. It won't be a component in any strategy for presentation of data on a website.
Symfony may be a "general framework", but it has scaffolding you can use as a complete application if your needs are simple. You define your model in a YML config file, and can then generate CRUD modules based on this model. The code generation is also customizable by editing other YML config files. All without writing any PHP code. But should the need arise, you have the option to extend the scaffolding with PHP and the complete framework.
See the Symfony docs on code generation.
A framework called ATK also claims a good code:functionality ratio ("An application in 10 lines of code").

Categories