I have recently come across a *sweet* online IDE, this would be Codio. Codio lets you develop in the cloud and run the code on an actual server. This way you can write your code and run it in the cloud, keeping your development environment universal and in my case safe-guarding against my own nonsense. While Codio does offer their own documentation on getting Laravel going, it uses Apache and MySQL. So here is getting going with Nginx, MariaDB, and PHP-FPM on Codio for Laravel development.
Create your project
Create a project just how you normally would, except select "Git" as the method for getting the base code into the workspace. This will give you an input where you can either put in an HTTP or SSH based git repository URL. If you are using SSH and you haven't setup the SSH key on your repository, it will prompt you to do so automatically with a key Codio generates. For now, I'm going to just use the standard HTTP URL for Laravel which is https://github.com/laravel/laravel.git .
Configuring the IDE server
Once your project is opened, you should be seeing the readme.md file from the repository opened in the editor along with the listing of files in the left pane. So, if you are seeing that, open up the Terminal ( Tools > Terminal ) to get the server setup.
The first thing we need to do, is install our web server and while we are at it let's grab mariadb, php, and composer. We manage software in Codio using a tool called "parts".
parts install nginx mariadb php5 php5-fpm php5-curl php5-pdo-mysql composer
Once this installation completes you will see some sectioned output on how to use the different installed services. One thing you may note, is mysql itself got pulled in even though we are going to use mariadb. This is because of a dependency within php5-pdo-mysql. This isn't a major issue, just remember to not start the service using parts and all will be fine.
Now that everything is installed, you will see the php5-fpm package gave you some nginx configuration to add. So, let's go modify the configuration for our server now while our mind is on it. Copy the configuration they give, then open the default configuration with vim like so:
Within this configuration, navigate under the location / {} block. Then go into insert mode, and just paste like normal. While we are here though, there are some other things that need to be edited. First, the root declaration within the first location block, move that outside into server {} and while you are doing that, append /public to the end. Now, within the location / block, add
Now that everything is installed, you will see the php5-fpm package gave you some nginx configuration to add. So, let's go modify the configuration for our server now while our mind is on it. Copy the configuration they give, then open the default configuration with vim like so:
vim ~/.parts/etc/nginx/conf.d/default.conf
Within this configuration, navigate under the location / {} block. Then go into insert mode, and just paste like normal. While we are here though, there are some other things that need to be edited. First, the root declaration within the first location block, move that outside into server {} and while you are doing that, append /public to the end. Now, within the location / block, add
try_files $uri $uri/ /index.php$is_args$args;
index index.php;
so that things will be send into laravel. Finally, just write the file and quit.Running the server
Now that the server is configured, let's install the projects requirements and startup the server to test things. Since we installed composer, all we need to do is run composer install from ~/workspace. Once that is done, startup mariadb, php5-fpm, and then nginx.
parts start mariadb php5-fpm nginx
Now we just need to have our preview open in a new browser window. To get this, click the down arrow beside the last menu item (Project Index (static)). Select "New Browser Tab" and then select "Box URL" (or the SSL version if you wish.) It will then instantly open a new tab, and you should be greeted with the all too familiar start page for Laravel.
Startup
Now that things are running, let's follow the path of the original guide from Codio and setup a startup script. This way when you open the project back up, the server will automatically startup as well. So, go into the root directory (~) for the instance (the one just above workspace). Then
touch startup.sh
and go into vim to edit that. Add a line to stop the processes, then one to start them again like so:
parts stop mariadb php5-fpm nginx
parts start mariadb php5-fpm nginx
Enjoy
Now enjoy your cloud-based IDE and don't worry about remembering to synchronize your settings across systems again.
Comments
Post a Comment