Multiple projects using Laravel - php

I recently installed Laravel and created a project on my webserver. I had to create a symbolic link for public_html to the public folder inside the Laravel folder. I realized that if I wanted to create another project, how would I do that?
I used to use CodeIgniter and setup was just placing it in a folder and typing the www.url.com/project1
www.url.com/project2
to access the different projects

Basically each laravel installation comes with a public folder. The public folder contains the index.php file, which is the entry point for all requests entering your application. This directory also houses your assets such as images, JavaScript, and CSS.
If you want to put laravel on sub directory, you will have access to sub directory's public folder. For example, www.url.com/project2/public
But a better solution of this is to create a sub domain and point the directory path to public_html/project2/public so you will have a working laravel on URL like this, www.project2.url.com
This is shared hosting solution and works for all laravel versions.

Related

How to configure codeigniter with site files in xampp?

I've recently taken over a project from another developer, let's call it EBAY. I'm struggling to get their live site up and running on my local server for testing and debugging. They've built a web app using CodeIgniter. In their file manager on cPanel they've placed the ci folder at the root, not in the public_html folder.
I've copied their public_html files and their ci folder into my xampp's htdocs folder. The issue is that the site only loads when the ci folder is placed WITHIN the folder for EBAY. Oherwise when I load the localhost site it gives an error message that it cannot find the codeigniter folder inside EBAY folder.
How is this? How can the application run with the ci folder at the root on the live site, but when I have migrated it to the htdocs of xampp it is expecting the ci folder to be inside the EBAY folder?
This kind of configuration is quite common nowadays, and if you look at Linux or Pear you'll discover that PHP files sometimes are completely in other directories than the webserver.
The ideas behind this are pretty simple but effective:
Any files can't be reached from the network / internet.
So they can't be altered, downloaded or even just viewed.
PHP (or other) Libraries are clearly separated from individual code and can't be easily mixed up or accidentally be deleted.
Access rights are easier to control and perhaps even that differently than the files in the webfolder.
Ok, so far an explanation. Now about your issue with it:
You've currently a webfolder htdocs in Xampp and in general you can use a subfolder as the webfolder and in htdocs directly you place the project files that are not public. You've to adjust then where the domain is pointing (docroot and/or virtual hosts).

Running wordpress with one of php frameworks

Is it possible to run wordpress as a sub url of a website (for example /blog) as the other urls are under control of a framework (like laravel or codeigniter) ? And if yes how?
PS: I don't want to use a different subdomain.
Yes , You can use , Simple put folder named as blog in root and install wordpress in that folder , if you are using laravel then you must create folder inside public folder and then install wordpress in that folder
for example
this is my domain at which i am using wordpress
https://www.coodingdessign.com/
this is another url at which core php are running
https://www.coodingdessign.com/php-editor/

Can I install a Laravel project in a subdirectory of my server?

I have a website that was built with just good vanilla PHP, no frameworks, etc. I am now needed to add a blog to this website and I am wanting to use Laravel / Statamtic to do so. My question is this:
Can I install a Laravel project in a subdirectory of my server? For example, www.mywebsite.com/blog/. Ideally, everything in the blog directory would operate with my Laravel code. Everything outside of the blog directory would just continue to work as is. Is this possible?
And if it is possible, is there something special I need to do in my Ngnix config file?
All you would have to do is take the contents in the /public folder and put it in the desired subdirectory, so "yourwebsite/blog". Then move the contents from the root laravel folder to outside the root folder on the server, so basically everything that is left in the project after you remove public would then go into say "/var/www/" if your root folder is "/var/www/html". After that simply update the path to the autoloader and app.php in the index.php file, which was previously in your public folder but is now in your sub directory. Keep in mind if you do this all routes in the laravel app will have to have the subdirectory as part of any relative url, probably simple to solve this with a group.
If you are simply looking to do a blog and already know PHP why not pick up wordpress and do a basic template for yourself? It's simple to pick up, a weekend maybe. If you consider it check out VCCW as a development environment.

PHP - First Time Installation of Laravel 4 on VPS

Hey so I am completely new to Laravel 4 and have some basic questions regarding my first time installation that I was unable to find answers to anywhere else on-line. I am planning of hosting a standard website with a fully dynamic web back end and a RESTful API using the framework. I have been following this installation guide and am essentially at the part where I type laravel new projectDir and it creates a new instance of Laravel in the provided directory.
Now my main public directory is public_html, is it recommended to install Laravel 4 directly into that directory. So is something like laravel new public_html recommended? I have found many other questions here that seem to suggest that this is not the safest solution. Should I make a separate directory inside public_html, is it necessary for what I am planning on doing with laravel?
Also, I would like to keep my URL's as neat as possible and would like them primarily to be www.domain-name.com/pagename for the website. Will creating a directory inside of public_html disable me from doing so?
Lastly I had some issues with routing my URL's when I tried to install a different framework on this server. Are there any server/Apache settings that would impact how URL's are routed with laravel that I should disable/enable before I install Laravel into a directory?
you would not put the base Laravel folder in public_html.
In a Laravel directory structure, which gets created when you do the laravel new command, there is a directory called public. This is what you map your web root to. So on my vps, I have a folder called /var/site/mywebapp which was created by the command:
laravel new mywebapp
In nginx (which I much prefer over Apache), I map my server root to:
/var/sites/mywebapp/public
In the public folder is an index.php that Laravel uses to run your whole app/site. The rest of the framework is outside of the web root and is not accessible by HTTP.
As for your URL issues, consult the documentation for how to properly configure your mod_rewrite (assuming Apache).
Also, Dayle Rees, a prominent member of the Laravel community (and core contributor), has a github of sample web server configs here:
https://github.com/daylerees/laravel-website-configs
When you install Laravel it will create a public folder, along with app, bootstrap and vendor folders.
The public folder is essentially your public_html folder where you want your host/apache to point to when viewing the root of your website. So mydomain.com should land directly within the public folder.
You can rename the public folder to public_html just be sure to also update bootstrap/paths.php paths value
'public' => __DIR__.'/../public',
// change to
'public' => __DIR__.'/../public_html',
Laravel will create a .htaccess file for you, which will grab URLs and redirect them to public/index.php which will process Laravel accordingly.
So to answer the question, you install Laravel one folder back from public_html and then you can rename public to public_html if your host requires.

CodeIgniter and normal website

I have a web hosting which hold a website I run.
I'm learning CodeIgniter so I would like to upload it a file in that web hosting and run some test and learn, CodeIgniter just for test, and keep using the website normally for users.
Is there any related or known issues or problem by running both ? I don't want the website to get frozen or act weird wit this.
Install codeigniter in it's own folder in a subdirectory instead of in the web root directory.
You will have to modify your config:
Installing a CodeIgniter application in a subfolder
Create a New Folder for your CodeIgniter Learning and Upload all CI files there including System folder and other.
If you Upload the the files with current website files folder it may create some issue.

Categories