Trouble Creating First Yii Application - php

Here is where I'm at. I am running MAMP on my Mac, and I have Yii in my htdocs folder. I don't understand the yiic.php part of it. I got it working once after numerous tries, but I the folder structure wasn't how I wanted it. So, with my folder structure being:
yii
framework>
requirements>
Where exactly would I navigate to in the Terminal, and what would I type. I've been navigating into to Applications/MAMP/htdocs/Yii and then once in there running this command:
php framework/yiic.php webapp testdrive
After that I get the Yes/No question, run "Yes", it does its thing, and I get this folder structure:
yii>
framework>
requirements>
testdrive>
assets>
css>
images>
index-test.php
index.php
protected>
themes>
Then I navigate in my browser to: http://localhost:8888/yii/testdrive/ and I get nothing...any idea what I am doing wrong?
Any help will be much appreciated! :) Thanks!

This is a long shot, but make the Y in yii a capital letter. This is assuming that the directory Yii does indeed have a capital Y in it. Unix/Linux machines have case sensitivity when it comes to these sorts of things.
As for your directory structure, you can have the Yii framework files live outside of your web folder if you want to. The "testdrive" directory is all you need inside of the htdocs folder. That said, the framework files can live in the folder as well, but it's generally considered insecure.

I got the same problem, but I am sure that I did not delete any file there. Fortunately, I try to restart apache server, and I revisite my test website, and it is working.
I use MAMP on Mac Lion. Hope this information would be helpful.

Related

How to access php project from localhost (Apache)

I know this question may first appear to be a duplicate of others, but I'm asking this because I have WordPress installed in my /var/www/html directory. I was learning WordPress a couple of years ago before creating a website and never used it again.
Well, I'm creating a php project using PhpStorm and testing in my browser. I'm following a tutorial so I can configure my databse (phpmyadmin), and the instructor keeps going to his localhost, which displays the directory structure as seen here:
Since I have WordPress on my localhost, navigating to that takes me to my WordPress installation, which is not what I want to access.
I would rather ask this question on here before I potentially break my Apache configuration, so how can I access this project? Do I need to remove WordPress completely? It would be nice to keep it for future testing since I'm slowly getting into making plugins.
What are your suggestions? I can't really say much as far as "what have you tried?" since I don't know where to begin.
Running in Chrome within my PhpStorm IDE takes me to localhost:63342/projectName/respectivePhpFileName.php, but I can't access it outside of the IDE yet.
Any help would be appreciated.
Just move your Wordpress outside your htdocs folder...I think he is using something like XAMPP so in that way is very easy to do it, because the folder without an index will be detected as a directory not a Wordpress URL (correct me if I'm wrong). So if that doesn't works, just go to your htdocs (/var/www/html or opt/lampp/htdocs in Linux) directory (or where your wordpress is stored) and move it to other folder (like My documents) where you can backup it, and that's it, you can create that folder and keep following that tutorial.

Why can't I create a new file in my working directory?

I am using PHPStorm 10.0.3 on Windows 7, and I have had no problems working in my project so far. But for some reason, I come into work this morning and suddenly I'm not able to create a new file in any of my directories in my project? This is the error that's occurring:
The error appears 2 more times after I click OK.
I am still able to go into Windows Explorer and create the file manually, so that will tide me over until this problem is resolved.
Thank you all in advance for helping me with such a silly problem.
UPDATE:
It seems PHPStorm thinks the project is "read-only" because when I try and create a new file in the root of the project, I get the error "Cannot modify a read-only directory" followed by the path. I tried using the attrib windows command to remove all read-only attributes but it still hasn't worked.
I'm not sure what fixed the problem, but I tried two things and I thought both of them didn't work. I'll explain exactly what I did for reference to fix this problem.
Firstly, I should announce that I (used to) use Google Drive for all my projects for automated backups. I think that may have messed with the permissions, so I took all my projects out of Google Drive and stopped the process. Didn't fix.
So, I did a combination of the following:
Right-click on the folder, go Properties, and uncheck the Read-only box and make sure it affected subfolders and files too.
Change the permissions on the entire folder so that I was owner, and that "Everyone" had full access to it.
After both didn't seem to work, I tried making a file in the root directory and noticed something about it being read-only. I found out about Windows' "attrib" command, so I performed "attrib -r -s /S /D project-folder-name" whilst in the parent folder of my directory. This also didn't seem to work.
It was at this point I wanted to know if my other projects in the same directory were affected. I closed the problem project, opened another project and tried making a file anywhere. It worked. I tried this for them all. They all worked. So, I went back to the problem directory... and it worked.
I think after making all those changes, I hadn't actually restarted PHPStorm or changed project. I recommend, when trying each of my steps above, restart PHPStorm completely or at least change project to make sure the problem project is closed so you can properly test if the step worked.
I hope this helps someone in the future.
On Windows check if the working directory you are trying to save your code to is added to Ransomware protection. That might be what blocks your IDE from saving files in that specific directory.
You find Ransomware protection by searching for Windows Security. In Windows Security choose Virus & Threat Protection then choose Manage Ransomware Protection and click on Protected folders. If the folder is present try removing it from the list of protected folders.

Using laravel in a subdirectory, without root access

A year ago, I decided to go with codeigniter instead of laravel, because codeigniter prooved to be easier to setup. I am now preparing for my next project and it seems as if codeigniter is now obsolete (at least most of the people seem to recommend laravel over codeigniter).
Now to my problem: I use a virtual ubuntu machine for developing web apps so I have a dev environment similar to the production environment (this helps me to avoid some problems (especially case-sensitivity...;)))
I installed composer and laravel and created a new laravel project named "quickstart" in /var/www/quickstart. I then followed their "getting started guide" (here: Guide). So far everything worked.
But here come the problems:
I have two other web applications in /var/www, so when I enter the ip of the machine I see the 3 directories.
Issue 1:
Normaly I'd expect that as soon as if I click on the "quickstart"-Directory in my browser, the webapp would get displayed, but I have to click a second time on "public", and then the webapp is displayed.
Issue 2: Of course, the links on the page are wrong too, because they reeer to (for example) "/task", which can't be found on the server.
The problem is that I'm not really experienced with apache configuration. I suspect it has something to do with VirtualHosts, but AFAIK you need to have root access to configure virtual hosts, and I do not have root rights on the dev environment.
Could you point out a way to me how I can make laravel work in a subdirectory in a way that I can just move the files and folders to my hoster as soon as I have finished the project? I'd like to then change only one file, and not all paths and URLs in all files ;)
Regards,
Christian
Thanks to Bogdan, I was able to figure it out. My hoster allows symlinks, so I did it like so:
I put the laravel installation in
/srv/web/quickstart
(quickstart is the name of the project). I then created the following symlink:
ln -s /srv/web/quickstart/public /srv/web/www/public
The document root of the apache is configured to
/srv/web/www/public
After that I just got a blank page. That was because I forgot to set the correct permissions on the storage-folder. So I set the following permissions
chmod -R 777 /srv/web/quickstart/storage
This is fine for a development environment. For production I'd recommend to only allow the webserver-user to write into that directory.
And voilĂ : Everything works!
Thank you for your help bogdan.
Christian

"Target folder cannot be created" when trying to make Netbeans copy sources folder

I'm trying to test a php app I'm working on in my Netbeans environment, and so I'm setting it up to run on a local Apache server. It seems to work fine when I manually copy my project into the htdocs folder, but when I try to configure Netbeans to automatically copy the sources, It tells me "Target folder cannot be created". I've tried changing the folder from read-only, including everything mentioned here but it doesn't seem to stick (Probably relevant to mention that I'm on Windows 7)
I could just keep manually copying it every time I want to test it, but that would be a major headache. Any ideas?
As I had guessed, it was a Windows permissions issue. After doing pretty much the same thing over and over without the change sticking, it finally stuck, and I was able to get things working the way I wanted. Sigh...

cant run php files in a folder on windows 7 webserver which was previously created on xp webserver?

im doing a php project. all is fine doing it in xp webserver which im using iis..but now i have set up a new pc with windows 7 and iis.
problem is when i copy my php files which is in a folder(e.g portal1) from the xp wwwroot to the windows 7 wwwroot, i cant access it on the browser. it returns an internal server error.
now i assumed i didnt properly set up my web server or even php. i have done it a dozen times following tutorials and im pretty sure its all correct.
i have done a further research on the folder itself and has led me to a theory that this has to do with permissions.
when i copy directly the whole thing,it wont run, BUT if i CREATE a folder and the subfolder with all the same names as the one i copied and just take the php files and put it accordingly, it runs ok!!
now that has something to do with inherited permission i think. how do i overcome this?
i dont want to everytime take the updated work folder from my partner which is done in xp and i have to create new folder and its subfolder with all the same name on my machine and then copy the php files accordingly. thats a lot of work!!
i just want to copy the folder and put it in my wwwroot folder and run it on the browser without problems. how do i overcome this permission issue?
any ideas?
By the sounds of things, you're working on a project with someone else. Copying & pasting is the absolute worst way of sharing files when working on a project with multiple people. You should really be using versioning like git. That's pretty hard to set up and learn though. An easy solution which will work for the time being (but won't manage conflicts well) is to use Dropbox. Set up a free Dropbox account, and create a folder in that called www or whatever you want. Then install WAMP (way better than IIS), and create an alias to the www folder in your Dropbox. Do this on both machines. Now every time your partner makes a change, it will be instantly reflected on your machine, and vice versa. Easy, free, and will work while you learn a versioning tool.
I know this doesn't address your actual problem, but it should be more helpful to you.

Categories