I am trying to get started with the PHP MVC framework, CodeIgniter. I am using the following article to setup my dev environment:
http://hetal.wordpress.com/2009/09/04/working-with-eclipse-and-code-igniter/
I am trying to add the CI 'System' folder to a new project in Eclipse. I am doing this by selecting 'New Php Project' and then 'Create project from existing source'. I am pointing it to the system folder as instructed.
I get an an error:
Parent of resource: /var/www/CI/System/.project is marked read-only.
The details says, "Permission Denied".
I have tried running Eclipse using gksudo but then I don't have PHP plugins installed etc.
It's saying that it only has read access to the /System/ folder, and therefore it does not have permission to write the .project file.
chmod the /System/ directory and try to import it into Eclipse again.
chmod og=rw /var/www/CI/System/
/* Gives the owner & group read & write access */
You're attempting to have Eclipse write files (i.e. the Eclipse .project) to a directory that it doesn't have permission to do so. It appears you're trying to write to the actual /var/www/ directory.
Normally the way I do it is to have CodeIgniter in my development directory/eclipse workspace and then make a soft-link in the /var/www/ that points to the Code Igniter I have setup in my development environment.
In response to comment
%> cd /var/www/
%> ln -s /home/jsmith/eclipse/workspace/CodeIgniter CI
This will create a soft link named /var/www/CI that points to the CodeIgniter you have in your home directory. (or where ever you typically put your development files) This will allow the web server to serve and use the CodeIgniter files that are under your control in your directory which you have full permissions on.
Related
Recently, updated a PHP project to use source folder and build folder. We're using Gulp to build the project from the 'src' folder to the 'build' folder after pulling the 'src' folder and project configuration files from our Git repo.
project_root
|
├── src
|
├── build
|
└── {project configuration files}
Both frontend and backend developers are currently running the 'gulp watch' we've setup to keep our 'src' and 'build' folders in sync.
One of this biggest annoyances we've encountered is while debugging our project in the browser we often open the offending file where an error is reported and tinker with the code until it works in browser. However, more times than I'd like to count, we make the change to a file in the 'build' folder while debugging and then we have to manually make the change in the 'src' folder (which is often overlooked at first).
Is there any way to fix this workflow issue?
Dueling Watchers Approach
I thought about making a two file watchers to detect changes in the 'build' and 'src' folders respectively. When either watch detects a change, turn off the other folders watcher, process the changed files and sync up the other folder, then turns the other folder's watcher back on.
(This seems like the sledge-hammer approach.)
IDE Approach
We PHPStorm and Sublime Text 3 depending on the developer. In Sublime Text, I simply exclude the 'build' folder from the project so I don't accidentally open it by default. (However, I accidentally open 'build' folder files when debugging the PHP too often.)
Other
Perhaps the way we're handling project structure in general needs work. Frontend and backend development is often done in concert. Any suggestions?
After flailing my arms wildly at this problem for a few hours after posting this I found an answer to my own problem.
Turns out the best way to handle this is to use the IDE Approach and create path mappings for your project:
PHPStorm (documentation)
Settings » PHP » Servers
Check the 'use path mappings' selection.
In our case we mapped the '../src' folder to '../build'
Sublime Text with 'Xdebug Client' package
Preferences » Package Settings » Xdebug » Settings - User
Add the following to your Xdebug.sublime-settings file:
{
"path_mapping": {
"C:/wamp/www/your-project/build" : "C:/wamp/www/your-project/src"
}
}
Once your path mappings are setup, you can successfully set a breakpoint in a php file in your '../src' folder run your debugging session and the file in your '../build' folder will breakpoint at the same location.
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.
I'm trying to configure Netbeans 8 to upload and test a simple php project. Here is the relevant setup.
Required project url:
http://services.mydomain.com/index.php
In the Project Properties-> Run Configuration
Project url: http://services.mydomain.com
Index File: index.php
Location of index.php via FTP:
ftp://services.mydomain.com/public_html/services/
As you can see I'm starting the FTP upload from a different place in the directory structure.
On the server
FTP directory: ~/ (This is the initial directory for FTP)
Web directory: ~/public_html/services/
In my project I have the folder structure:
Source Files
-> config
-> public_html
--> services
----> index.php
I want to keep this setup so I can have some configuration setting outside the web directory in ~/config. Also I don't have admin on server so can't change the initial directories anyway.
The problem is Netbeans is doing validation on the Index File location it wants to see the public_html/services/ in the Index File field (because this is where it is in the project) This gives the URL:
http://services.mydomain.com/public_html/services/index.php
Which is wrong.
The error I am getting is "Index File must be a valid URL".
Does anyone know of a way to turn this validation off so I can manually set my own URLs.
I am using NetBeans 8.2, but this should work on earlier versions. Also, you can look at the following blog for Path Mapping, but I didn't need that.
To solve this:
Open the Project Properties dialog.
Select the Sources page.
In the Web Root directory path, click Browse...
Navigate to the directory that is your website root and click Select Folder. In my case it was the "public" directory in the Laravel project directory.
Click OK.
Hope this helps someone else.
I am using NetBeans 12.6. For my Laravel project I created New Project in NetBeans "PHP Application with Existing Sources".
My index file located in my-project/public/index.php
So, I defined in the last step of my project configuration in NetBeans:
Project URL: http://local.my-project.com/
Index File: public/index.php
I logged into openshift application using filezilla.
Earlier for normal website i just drag and drop files at www directory its works pretty fine but in at this case i found some other folders and i am unable to get an idea where should i drop my php app in at this particular machine. I am unable to locate where the index file is located also. if I am using git for the deployment of application it works pretty fine.
Openshift makes it easy to upload program changes by checking out the container. Adding the code and the pushing it.
see How to git-checkout first application created on OpenShift? on how to do that.
I'm not sure about the structure when you use filezilla to connect to the Openshift container, but it should be similar to the checked out structure
index.php Template PHP index page
.openshift/ Location for OpenShift specific files
action_hooks/ See the Action Hooks documentation
markers/ See the Markers section below
pear.txt List of pears to install
Depending on what cartridge you are using:
php/ # for backward compatibility with OpenShift Origin v1/v2
public/ # Zend Framework v1/v2, Laravel, FuelPHP, Surebert etc.
public_html/ # Apache per-user web directories, Slim Framework etc.
web/ # Symfony etc.
www/ # Nette etc.
./ # Drupal, Wordpress, CakePHP, CodeIgniter, Joomla, Kohana, PIP etc.
See https://developers.openshift.com/en/php-repository-layout.html for more details.
try this:
goto app-root > repo
put your files in this folder. if you put a index.php, it will be accessible through the web.
but there's a more convenient method.
create a folder name php inside the repo folder and openshift will use it as a document root. which means all other files will be unaccessible from the public.
conclusion
put all other files in app-root>repo. put the index.php in the php folder and link other files accordingly.
optional:
use GIT. its easy and way more convenient than sftp. you need to learn only 4 commands.
git add
git commit
git push
git clone
that's it!
edit1
IF php/ dir exists THEN DocumentRoot=php/
ELSE IF public/ dir exists THEN DocumentRoot=public/
ELSE IF public_html/ dir exists THEN DocumentRoot=public_html/
ELSE IF web/ dir exists THEN DocumentRoot=web/
ELSE IF www/ dir exists THEN DocumentRoot=www/
ELSE DocumentRoot=/
above is the priority of document roots in openshift. use whatever you like.
Had the same problem. You need to turn off APC cache. This can be done via an .htaccess file:
php_flag apc.cache_by_default Off
The directory structure of my project is like this:-
/var/www/includes/
/var/www/classes/
/var/www/public/css/
/var/www/public/js/
/var/www/public/index.php
The webroot is /var/www/public, so accessing the test domain localhost.dev would serve the files inside the public directory and hence would run /var/www/public/index.php. No need to access like localhost.dev/public/index.php
The problem is when I create the project in Netbeans, I have to set the index file so that the project can be debugged using xdebug and Netbeans.
So when adding the project I provided /var/www as Project source folder (Sources Folder) as the includes and classes are in this folder. In the next project configuration screen (Choose Project > Name and Location > file path is taken as Run Configuration), I'm asked for the Project URL and the index file. Since the index.php file is actually under the /var/www/public/, when I browse the file and select it, the url to index page is taken as localhost.dev/public/index.php instead of just localhost.dev/index.php. This is preventing me from debugging the project.
Can anyone please point out how to add projects to Netbeans when all the source files are not in web root and the project is to be debugged using xdebug.
I think its a bad practice to put all the project files directly in /var/www.
I think you will never see that in real deployed projects. So my first recommendation will be to change the way you are structuring your project. If that's not possible, in Netbeans select /var/www/public as the Project folder.
If Netbeans need references to the folders in /var/www, create symbolic folders inside public pointing to those in /var/www.
The last resource you have is to create a rewrite rule in Apache to make localhost.dev/public be the same as localhost.dev. You can look for this in Apache documentation.
I have a similar set up with one minor difference: my setup uses a remote site on my local development server. On the "Run Configuration" window of the project properties, I set "Run As" to "Remote Web Site (FTP, SFTP)". I don't think this affects the information in my answer, but I'm mentioning it just in case.
Go to the "Sources" window of your project properties, find the entry for "Web Root", click "Browse" and select the /var/www/public directory. That should cause xDebug to use localhost.dev/index.php. You'll notice when you go to the "Run Configuration" window and browse for the Index File that the browse window will start in "public" rather than "www".
An important note about this type of configuration that caused me a great deal of frustration.
When using xDebug, you'll want to be able to set breakpoints in and work with the files outside of the web root (public) directory. Because you've set the web root to /var/www/public, you won't be able to work with the files in /var/www/includes or /var/www/classes.
The thing you need to do is to add the files outside of your web root to the Global Include Path.
There are two methods for adding directories to your Global Include Path, which one you use depends on how you've configured your project.
In your case, the external directories are included in your project, so you need to add them via the "Options" interface. Go to Tools->Options and select the "PHP" tab, then add the /var/www/includes and /var/www/classes folders to the Global Include Path.
The other method for adding files to the Global Include Path is for files that are located outside of your project source folder. For directories like /var/folder_outside_www/, you use the "PHP Include Path" window in the project properties.
I haven't found a better way but I use this steps:
Menu:Project Properties -> Link:Run Configuration -> Button:Advanced
Debug URL, choose: Ask Every Time
Path Mapping, Server Path: http://localhost.dev/ ,Project Path: /var/www/public/
Now, when you start Debugging process, Netbeans will display Specify URL pop-up which you can change from http://localhost.dev/public/index.php into http://localhost.dev/index.php
Set /var/www/public as project folder (contain netbeans project folder) and include in project properties /var/www/includes/ and /var/www/classes/ as global include directories. Or best way use PHPStorm.