I am new to laravel , composer and frameworks.however i have managed to install laravel on my pc via composer. and i have created a project with it using
composer create-project laravel/laravel your-project-name --prefer-dist
But i got a directory with my projectname on my current working directory with plenty of files in it.
I need to know wheather i could use this same files by copying the files in the folder and using this as my base for all my other projects..or do i need to run the composer command every time? Even if i run it i gets the same files, which i got now right? So could i just backup the files in the folder i got and use it as my base files?
Well unless you don't have an internet connection there's no point on creating a backup.
Laravel is modular and has external dependencies, so whenever you are creating a new project with composer you are fetching the most recent modules and the most recent Laravel version. But if you use a backup version you might be developing for an outdated version with critical bugs.
Another cool thing is that if you work on different computers, like you have one at work and another at home you don't have to be carrying your backup so you can start a new project by just doing:
composer create-project laravel/laravel your-project-name --prefer-dist
Also I never tested, but I think it takes more time copying a brand new Laravel install with it's dependecies than using composer.
Composer Offline
Another nice thing about using composer is that it stores everything in it's cache. So imagine this scenario we have an internet connection and create a new Laravel app
$ composer create-project laravel/laravel APP1 --prefer-dist
Now disconnect your internet, create another folder and install Laravel again
$ composer create-project laravel/laravel different-APP2 --prefer-dist
When you run the second time and since you don't have internet it will fetch everything from composer cache, but they will be two completely different applications with their own app names and their own application keys
You could use this files again, but you won't get the same files running the command every time, since the latest version of the laravel project and its dependencies are downloaded.
The project files are updated regularly. So if you don't have limited bandwidth, you should just create a new project every time.
Related
Does composer provide a way to update the package a project was created with? i.e., if I create a new laravel project with the following
composer create-project --prefer-dist laravel/laravel blog
Composer will grab the latest version of the laravel/laravel package, unarchive it into the blog folder, and then run composer install from the blog folder.
What I want/need to know is, does composer provide a way for me to update the laravel/laravel package that was downloaded to the blog folder? I know I could run composer update inside the blog folder myself, but this will only update things listed in the compser.json's require property — it will not update the unarchived laravel/laravel in blog (or will it?)
As far as I know it's not really possible.
Imagine that you create a new as example Laravel project.
The composer create-project creates the skeleton with all initial routes in your configuration etc.
From the very very first moment you are starting to change the default routes, removing the default controllers and changing the default views, your project would be out of sync. because meanwhile laravel changes the skeleton to newer versions with some new default routes etc or event changes directory structure.
It would be really hard to merge those changes over your existing application.
A better solution would be to follow the "Upgrade guides" (laravel: https://laravel.com/docs/5.4/upgrade) and then just commit those changes to your own project.
If you want to upgrade to a new laravel version, you can always follow the upgrade guide for your specific version:
Laravel 5.8 to 6.0
Laravel 5.7 to 5.8
Laravel 5.6 to 5.7
Laravel 5.5 to 5.6
If you are more than one version behind, you need to apply the previous upgrade guide. So if you are on 5.6 and want to upgrade to 5.8, you need to follow the guide for 5.6 to 5.7 and then from 5.7 to 5.8.
The guides are pretty helpful: they tell you which package must be updated to what version and inform you about deprecated methods which will be removed in the upcoming versions.
Another method which you can use to upgrade to new minor versions is to just look at the differences from one laravel release to the next. That way, you can see what exactly has changed and which files are new (configuration files for example which you can copy and paste into your project as the default composer create-project command would do).
As for the current version, you can see the commits since last release here: v5.8.30 to 5.8
Directly under the headline for a release, there is a small link labelled "36 commits to 5.8 since this release" which will take you to the link above, just for the latest version.
That's not the goal of composer, that just manage your packages.
You should see composer create-project just as a shortcut of git clone + composer install. If you need to deploy your application you've multiple options, from a simple git pull, to more advanced deployment tools like Capistrano. But composer isn't one of these tools.
I just needed to do this, and I couldn't find anything simpler than a git clone and a git pull (as #Federkun). Maybe an alternative would be to publish a phar file for the project and download that?
I can see db-ping does this. It's based on joomla/using phar. Here is the main file for building, inspired from joomla's file.
(don,t get angry with that)why we use composer i searched in google it says it is used for the dependencies of laravel, but why we create project in composer?cant we create it in simply in xampp/htdocs/laravel/... there as in past they does in codeigniter?explain it simply and clearly, what is the purpose of using the artisan commands, like php artisan serve that create a host address like localhost:8000 cant we go there in browser simply like localhost/laravelproject?and does composer works offline,without internet access,i mean entering those commands in cmd prompt?simply my concept is not clear with using composer with laravel, clear my concept...thanks
As google said, composer is always for dependencies, not just laravel but in any other framework or libraries, composer is used to automatically download dependencies needed for code to work.
Laravel is based on some packages that are some kind of third-party packages. When you create a project in codeigniter you copy all files needed for project. You can do this in laravel too, but you should have all files that are needed. Now you can download all files manually or just set those files and libraries in a file named composer and let composer do that for you. And even if there are dependencies for libraries that you mention for composer, composer detects them and downloads them too.
When you create laravel project with composer, you can save all files and use them for another project (as I did), and not to use composer again.
Artisan commands are just here to help you. Many of commands that are supported by artisan, are possible to be done by your hand, but artisan is here to help you.
Of course you can use xamp or wamp to host your laravel project, here serve command is another option to serve your project. You do not have to use it (as I never do).
Composer does not have dependencies and it just detects dependencies and downloads them.
Hope that helps.
I would like to store my new project in my company's git repo. The project will use cakephp 3. But frequently after setting up a project and pushing it I get some trouble: A coworker clones the project to his pc and it comes with missing directories (mostly "vendor"), and we frequently get problems with debug kit (need to remove the database file after every git pull).
Is there some recommended procedure to create this kind of project?
The recommended strategy for composer-backed PHP projects is as follows:
Add the vendor directory to gitignore.
Commit composer.json and composer.lock.
When your colleague begins development they just need to run composer install, and the committed composer.lock file will result in the right dependencies being downloaded.
In the console I will type below.
Composer create-project laravel/laravel "MyLocation" --prefer-dist
This will start downloading everything.
Question: Can't we copy the framework from previous created project ? Is that necessary every time to download everything from scratch ?
You can copy the existing Laravel projects if you want. But, you may need to modify too much of the parts for your new project.
Downloading a new one is the better option. In my personal opinion, make a laravel base project then push it into your git repository and whenever a new project starts, you only need to pull or fork from the repository and start building.
I am currently trying to install Omnipay into my Codeigniter project. I am stuck on windows because I do not have ssh access to the box where this needs to run on. So far I have gotten a new directory in the project root that is named "vendor" and it contains a lot of empty directories referring to Symfony (for what reason is beyond me).
Then I get a runtime exception that I need to enable the openssl extension in my php to download the necessary files and this is where I am stuck at. I don't run WAMP on my computer and I just use the php.exe I downloaded to work with netbeans.
Isn't there an easier way to get omnipay to run? Like just download the files from somewhere and plug them into my project like normal? It seems to be an aweful lot of headache to get a simple library to run in my CI project.
Please forgive my ignorance towards composer but I currently see no benefit of using it for this particular project.
You can "just download" the files here: https://github.com/omnipay/common/archive/master.zip
The problem is, Omnipay depends on Guzzle (an HTTP library), and Guzzle depends on some Symfony components. So you will spend the rest of the day downloading dependencies and making sure you have all the necessary files. That is the problem Composer solves for you.
I don't have any experience running Composer on Windows, but I would start here:
http://getcomposer.org/doc/00-intro.md#installation-windows
Using the Installer
This is the easiest way to get Composer set up on your machine.
Download and run Composer-Setup.exe, it will install the latest
Composer version and set up your PATH so that you can just call
composer from any directory in your command line.
Once you have Composer installed, you should simply be able to make a file named composer.json in your project root, with the following contents:
{
"require": {
"omnipay/omnipay": "~2.0"
}
}
Then use the Command Prompt and cd to your project's directory, and run composer update to download the Omnipay files and all their dependencies.