Netbeans and Codeigniter Applications - php

I'm still trying to figure out how to work with netbeans and codeigniter projects. I have the following structure tree and I am trying to figure out tht when I open up http://localhost/MyFirstProject that it'll use the index.php file that resides in the site folder. Anybody use netbeans here and can tell me. I've already started the project.
Projects
- MyFirstProject
- Source Files
- application
- site
- assets
index.php
- system
- Test Files
- Important Files
- Include Path

It looks like you're using a bit of a non-standard layout, but you can change the index.php file like this:
In the project explorer, right click on your project MyFirstProject
Select Properties
Select the 'Run Configuration' category
Modify the 'Index File' field to point to site/index.php (you can use the browse button to select it)
Enjoy :-)

Related

Is there a way to create an Eclipse project excluding the project name in the path?

Not sure how I can explain this better as I am a beginner to Eclipse application.
I have my web directory set up for php pages. For example, /home/www/phpsite. All the source files exist here.
However, whenever I create a project (say 'myProject') and test any files from the existing path, it includes the project folder in the path name:
/home/www/phpsite/myProject/index.php
and this results 'Not Found' error.
How can I run my php pages in /home/www/phpsite/index.php? The project folder name is always included in testing web pages.
I am not trying to use the workspace directory created by Eclipse. I'd like to code and modify pages directly from Eclipse to my web directory.
Thanks
Follow these steps:
Setup www as your workspace
From the menu: File -> Import -> General -> Existing Folder.....
Promote to project:
Choose project type: PHP
Browse for "phpsite" and finish.

Can you turn a folder of PHP files into a netbeans project?

I have a folder with several subdirectories containing PHP files. At the moment I open each file individually in Netbeans. However, I would like to open this folder as a project, so I can use features like searching for a line throughout the entire project. Is this possible in Netbeans? What would be the best way to achieve this?
Create a new project, set sources directory to the one you have with current files
(might want to back up the files before if anything goes wrong).
Go in Netbeans. Select Files->New Project. A window will open, in that select PHP in Categories. Click Next. In Project Name give the name of your project(as seen in netbeans), in Sources Folder select the path to your project and click Next. In Run Configuration Make the settings according to your requirement to run the project. Now in PHP Frameworks Select ypur desired framework or just leave it blank and click FINISH.
You will See your project in Netbeans now.
Go to file->New Project and select PHP in category and follow the instruction.
In Source folder you need to choose your files folder so that it get listed.
go to FILE->new Project->select php in categories in left pane and php application with existing sources as Projects *in the right pane* ->next -> next till finish
When you add any directory in netbeans as a project, it add its only directory under the project directory. So if you need to add the numbers of directory in netbeans being a project, then i would like to suggest firstly to collect all directory in parent directory. then add it as a project.
Here is an explaination:-
directory- dir
lets you have dir1, dir2, dir3, dir4.
and according to you mentioned above all dir are projects.
You have to create a dirA and all dir1, dir2, dir3,and dir4 are subdirectory of dirA.
so the folder under dirA nbprojects(created by netbeans) will take care of all directories being the subdirectory of dirA.

phpstorm, subdomain handling

I have a project with some php and html files. URL for this project, for exmaple, - mysite.com
I need to create a subdomain for content, that will be moved to CDN: assets.mysite.com
Now, during development time, all files for subdomain are stored in a subfolder of my project /home/user/phpstormprojects/mysite/assets
In my html/php files I need to specify full path to my assets
html://assets.mysite.com/mybest.png
Of cource I want autocompletion and other features to work well.
So I need to set up phpstorm smth like "assets.mysite.com" = "/home/user/phpstormprojects/mysite/assets"
Could I do it?
I am using PhpStorm 7.1.3
Ensure your cursor has highlighted the project name.
At the menu on top select "File" then "New" then "Directory".
Name your directory. It will go under the project name (see step 1).
Right click on the new directory then select "Mark Directory As" a
pop-up will appear giving you the option to mark the new directory
as "Resource Root".
Put whatever directories you want inside it. PhpStorm will rename all references to them in your code.

CodeIgniter 2.1 and SimpleTest - Conducting a simple test

I am currently using CI 2.1 and Netbeans 7.0 as my inveiglement IDE. I would like to create some simple unit testing using SimpleTest. In particular the methodology used by Eric Barnes and his code found at Git Hub CodeIgniter-SimpleTest. (https://github.com/ericbarnes/codeigniter-simpletest)
I have created a new CI application using Netbeans 7.0 and connected to my database (which contains 1 table called schools with the typical schema schoolid, schoolname, schooladdress etc.). I have created a controller (simpleapp), which loads a model called schools_model. The schools_model gets all the schools using a method called getAll(). Another method called getSchoolName(id), accepts a school ID and returns the school name.
The controller then loads a view called schools_view to display all the schools. Pretty simple stuff…....... and it works flawlessly, displaying all the schools when I point my browser to
http://localhost/SimpleTest/simpleapp/getAllSchools
(I am also using a .htaccess file, hence no index.php)
My question is this….......
How do I get SimpleTest to work using the Git hub code supplied by Eric?
I have followed Eric’s set-up advise, but don’t know what URL to point to to create the screen dumps he provides. I have maintained the directory structure Eric suggests but haven’t had any success. Eric suggest to point the browser to yoursite.com/unit_test.php, but I get a
404 page not found error for localhost/SimpleTest/unit_test.php
I assume the above error is due to the fact, like most CI applications, we need to use a controller first.
I would appreciate any direction in this area.
I have done exactly what you suggested. I have placed the unit_test.php file in the root directory and set up the test directory structure as suggested. However, when I point to localhost/SimpleTest/unit_test.php I get the 404 error.
My directory structure looks like
Source Files
-application (folder)
-system(folder)
-tests(folder from git hub with model/test_schools_model.php)
-.htaccess
-index.php
-licence.txt
-unit_test.php
Is it a .htaccess issue the reason I cannot view localhost/SimpleTest/unit_test.php?
You are correct you need to go to yoursite.com/unit_test.php or in your case localhost/SimpleTest/unit_test.php
You need to copy the unit_test.php file from github into the sites root directory and place the tests directory there too. You then put your tests in the appropriate folder under tests/

How do I get CakePHP configured so it shows up correctly in my browser?

I am a cakephp newbie and I had trouble to view the files under the view folder through browser.
I used cakephp console to bake model, controller and views. (ex: Invoices_controller.php for controller, invoice.php for model and a invoices folders under views folder). According to the tutorial I read, I can access the invoice view by typing http://localhost/myProject/invoices
(there is no index.php inside the invoices folder..but the tutorial shows it still can display a page. no idea how they did it)
The path for my invoices is myProject/views/invoices and there add.ctp, index.ctp, edit.ctp files inside the invoices folder.
The browser showed the file is not found when I typed http://localhost/myProject/invoices
You have some lack in your knowledge about how the webserver handling a request when cakephp is installed. Assume that we use apache.
In cake's folder structure you can see .htaccess files in the root, app and webroot directories what have url rewrite rules in them. At the end a normal request to a cakephp site will be transformed to a http://site.url.root/app/webroot/index.php?url=original.url
In nutshell to understand it in your point of view:
That index.php call the required php files and at least a cakephp app object is built up in the memory with the required models and methods. Then the app object let say start and calls its methods (model, controller and view methods) and at the end it gives back a result to apache what serves it to you.
Therefore the original url path is a "non existent" virtual url.
If you enter http://localhost/myProject/ do you get a cake intro page? If so does it highlight any problems?
It sounds to me as if you do not have Apache set up properly. I don't know what OS you're using, but it might be worth checking this link, written for Ubuntu, to make sure all is well: http://leoponton.blogspot.com/2010/05/getting-cakephp-up-and-running-on.html
I fixed the same problem.
if you are using windows 7 os, wamp server, cakephp 2.2.3. then
goto apache -> http.conf -> open -> search for mod_rewrite -> uncomment the line LoadModule rewrite_module modules/mod_rewrite.so
Now restart your server, now it should work fine.
Jerry, I think the issue is this. You have put the CakePHP folder in the root of localhost. I would propose that you create a virtual host pointing the myProject so the url becomes:
http://myProject/accounting
This may solve your problem. Be sure rewrite module is on. Also, when you point the virtual host to myProject, it should be the APP folder of the cakephp. If you want to run multiple projects off the same core, you can set them up like so:
/var/www/cake
/var/www/html/myProject
/var/www/html/myProject2
The /var/www/cake directory is where you drop the cake core. Under this directory you will have cake, app, plugins, vendors, etc. the myProject(2) directories will be the contents of the app directory.
Now, to get this to work, you need to go to /var/www/html/myProject/webroot/index.php and edit it to point to the cake directory in /var/www/cake. This will then load the core when rewrite points to index.php in webroot. You should be good to go!

Categories