Changing laravel file structure - php

I am new to Laravel and PHP programming. I am building a web application using laravel framework. When I create project using composer create-project it creates laravel files inside the laravel folder and I move all the files out of laravel folder and delete the empty laravel folder as belo.
-root folder
--app
--bootstrap
--config
--database
--public
-----------
After, I pushed the project to github and clone it from another computer and to add laravel files I execute composer install. Now laravel framework files are created inside a laravel folder instead of root directory.
-root folder
--app
--bootstrap
--config
--database
--public
--laravel
----app
----bootstrap
----config
----database
----public
How can I change the location, composer create the laravel framework files?

If you want to install laravel with composer then you should follow bellow this way:
Firstly install Composer according to your operating system.And then if you use xampp then create a project folder or run a command composer create-project --prefer-dist laravel/laravel blog this will create a root folder and a sub-folder named laravel.
Your problem is that when you secondly clone git form github that time you mixed up the main root folder that's why its duplicated.
I think you should re-install again according the given procedure.Hope this will solve your problem.
Another way: if in your pc have installed composer then you just clone the git and after that in the root folder (cloned git folder) run the command composer update.It should solve your problem.
Tricks: For opening root folder with command for windows operating system. Press select the root folder and Ctrl + Shift + right button of mouse then click the options Open command window here .
LARAVEL DOC.
Thanks.

Use this to create Laravel project
composer create-project laravel/laravel YourProjectName

Related

The provided cwd "/home/www/myproject" does not exist

I used to map only one folder to my projects root folder as recommended in Laravel 5.6.
Now, I mapped each folder to each separate project as recommended in Laravel 6.x.
Now if I login into my VS with vagrant ssh and try laravel new myproject I get
The provided cwd "/home/www/myproject" does not exist
If I create the folder beforehand, than I get
Application already exists
If I install as root, then Laravel gets installed, but I can't find my project on my PC. I see it on my VS, buts it not on my hard-drive.
This is the config in my Homestead.yaml:
- map: ~/www/homestead/myproject # Path on my laptop
to: /home/www/myproject #Path of VM
I find /home/www/myproject which I created on my VS, but ~/www/homestead/myproject does not exist on my PC.
I did not have these issues when I was only mapping one folder. How can I fix this and create a new Laravel project?
I solved this by installing Laravel command globally with composer on my PC. To do so, I had to install zip first:
sudo apt-get install php7.2-zip
Then I could install it globally
composer global require laravel/installer
Which displayed
Changed current directory to /home/adam/.config/composer
and I had to add this to my ~/.profile:
PATH="$HOME/.config/composer/vendor/bin:$PATH"
I reloaded profile in command with source ~/.profile and then I finally could install Laravel from my PC instead from the VM.

How to Clone Laravel Project and Run on Mamp

I have an existing Laravel project I want to clone from GitHub.
I normally run Laravel on Homestead/Vagrant.
But this time I need to run it on Mamp.
I already cloned the project into my htdocs folder.
When I click to see my website, I see Index of/ then all the files.
Index of/
.env.example
.git/
.gitattributes
.gitignore
.phpintel/
app/
artisan
bootstrap/
composer.json
composer.lock
config/
database/
gulpfile.js
package.json
phpunit.xml
public/
readme.md
resources/
scratch3.php
server.php
storage/
tests/
What do I need to do/change/configure so my Laravel website works properly.
I'm on a Mac.
According to my experience, there are some steps for setting up an existing Laravel project as follows:
Install PHP and Composer
In your Laravel dir, run composer install
Then copy .env.example file to .env
Open .env and change a database connection information and save file
Generate the application key by using a command php artisan key:generate
Run a migration if exist by using a command php artisan migrate
Then run composer dump-autoload
Finally, start your project with command php artisan serve or create a shortcut in a public directory or Mamp and link it to public folder of your Laravel project.
Hope this helps, any comment is welcome.
if you click your website and you see your root you probably need to configure your settings a bit, maybe this will help
How to get htaccess to work on MAMP

Laravel Install with Composer is Creating Two composer.json Files

I am just getting started both with Composer and Laravel.
I used Composer to include the Laravel installer:
"require": {
"laravel/installer": "v1.3.5"
}
When I ran the Laravel installer, it created a subdirectory with the name specified in the command: laravel new name. My project now has a composer.json file in both the root folder and the Laravel installation sub-folder.
Is this what's supposed to happen? It seems to me that I should only have one composer.json per project.
The best way to create a Laravel project using composer as describes below:: (on windows)
First go to file directory where you want to create the Laravel project say "C:\xampp\htdocs\laravel_5_4"
Press Alt+d then you will see directy URL will be highlighted, then type "cmd" and press Enter and command promt should appear.
Then just copy these code "composer create-project laravel/laravel ./ "5.4.*" --prefer-dist" and press Enter.
Sit back and relax, you are done.
Note: You can change the version as you want.

How to start a Laravel project in CMD via Artsian commands

I'm learning Laravel and they say in order to create a new laravel site you have to make your folders like this:
--webshop
--root
--laravel (contains the laravel files)
--assets (contains the css,fonts,img,js from the public folder of laravel)
--.htaccess
--favicon.ico
--index.php
--robots.txt
--web.config
So as you can see I cut the containers of public folder inside Laravel and paste them in the root directory. So now I want to start the project and make it live on the localhost using Artisan commands but I don't know in which folder I have to make it live... For example root directory or laravel directory inside of root or something else... So can u please help me!
No, that's wrong. install laravel by composer like this:
composer require --prefer-dist laravel/laravel mysite
from inside mysite start project by run the artisan command php artisan serve and enter in the browser the url 127.0.0.1:8000
more information here
Have you checked Wamp or Xampp if you're on Mac/Linux, it's a PHP local server with phpmyadmin if you want to test out with a local database. Also have you created your project with composer create-project --prefer-dist laravel/laravel nameofyourproject? It installs all the basic folders you need to start using laravel right away, you can then copy those files on Wampp/Lampp and use localhost.
Refer to the documentation here:https://laravel.com/docs/5.4
If you have composer installed, use:composer global require "laravel/installer"
Now, to create a new project simply run : laravel new ProjectName.
No need to create a directory structure on your own.

Installing laravel on existing project

I'm developing a laravel application and my computer die.
Now I want to get my project from the repository (Bitbucket + Git) but thanks to the git ignore file, the vendor folder is missing. I can't do a composer install on my project because is not allowed (the directory should be empty). The structure of my project is the same as the laravel installation except that I renamed the public folder.
I found this thread but did not solve my problem.
Integrating existing project by laravel framework?
I wanna know the best practice or way to do this and i don't think that copy and paste the folder of my project to a fresh install of larevel should be the way.
Thanks.
Go to your www folder
cd /var/www
Git clone your application (not that here the directory must not exist):
git clone https://github.com/antonioribeiro/application
CD into the folder
cd application
Execute composer update (if you are in a development environment)
composer update
Or execute composer install (if you are in a production environment)
composer install
Note that for composer install or composer update, the folder may actually have files and even a vendor folder created, there is not such obstacle.

Categories