Manually laravel 5 package install in project - php

I have install a new laravel 5 project. In my other project i have several packages. I want to install my expected packages from copying package from vendor folder and paste into my new project. I want to do that because composer is really slow to install new package from online.

You just can't install manually because it will be a lot of task then. e.g when Laravel installs through composer it has some scripts which runs at different steps of install it copies .env file it generates key etc. You can see https://github.com/laravel/laravel/blob/master/composer.json#L31 & https://getcomposer.org/doc/articles/scripts.md#event-types. Now you can copy paste of your full previous code & remove controllers, models, packages from composer.json. But if you manually install it won't be a wise decision.

For composer You can use https://github.com/hirak/prestissimo
It gives you the ability to install packages and dependencies in parallel mode. This gives a huge boost during installing projects/packages.

Related

Create a customized laravel base Project and install it for future projects

I install a new Laravel project and I have been applied Many changes on it for my own purposes. for Example my custom admin panel design and related css and javascript files.
In addition to, I added some packages that are required on whole project.
Now , if I want to Start a new Project , I must to install a fresh laravel Project and add those files and packages manually again that It takes a lot of time.
Is there a way that I could store this base laravel project on it (for example Github) and install it via composer?
Yes, you can use Github to create a private/public repository then when you start e new project you clone that repository and then use composer install command to get the dependencies.
Yes, it's possible.
Here are all the steps :
git clone xxx.git
composer install (make sure you have included .env.example in your git for the app key)
npm install
bower install
php artisan migrate (if, I hope, you use migrations)
gulp
And you are ready to work on your project.

Getting started with laravel

I just started my laravel course with laracast. I dont quite understand yet all the enviornment-related things.
I know that Composer is a kind of a program that downloads pre-written scripts to use in your project. But where does it work? On my local machine or on my vagrant homestead box VM? On which of these is it supposed to be installed?
I installed myself vagrant homestead box already but does it contain composer? When I go ssh into my guest machine and go to vagrant#homestead:/vagrant$ path I can see composer.json and composer.lock files, but does it mean that I have composer installed?
Composer is a PHP package manager, like npm for javascript or pip for python. There are many examples of package managers. It's useful, because adding dependencies to your php projects can be a pain, but composer makes it really easy. You just add the dependency to composer.json and you can use it right off the bat.
Composer isn't laravel specific, you can use it in any php project, laravel uses it to manage it's dependencies, laravels dependencies use it to manage their dependencies and so forth.
If nothing else, the composer autoloader is great, so you can use it even if you don't plan on using external packages.
Homestead should come with composer installed. A composer.lock file is generated when you run a composer install or composer update. If you plan on creating or using other php projects on your machine, it's probably a good idea to have composer installed on your machine as well.

Newest symfony installer vs composer

I'd like to know whats the difference when creating new symfony project with new symfony installer that has appeared last time and old-way composer.
I've installed latest version of symfony (2.6.1) with both, and result was different, for example when I install symfony with composer, i get .gitignore file.
When I install with new symfony installer script, gitignore is missing.
Here is amount of catalogs and files in fresh project:
symfony installer: 1498 directories, 7136 files
symfony installer + composer update: 1571 directories, 7749 files
composer create-project: 1615 directories, 7905 files
I suppose I'll stick to old way - composer, since new installer seems to be bugged or at least not complete yet, however I'd like to understand more on this topic, whats the difference, is it safe to use new installer etc?
As Leggendario already explained, the installer downloads the dist files from the website (a .tar.gz or .zip file). This speeds up the installation process quite a bit.
However, when building the dist files, symfony.com uses a custom build script which removes some files and changes some things. On the other hand, composer simply downloads the repository for you.
The main differences:
Composer downloads the latest dependencies (as Leggendario pointed out), while the build script contains the latest files at the moment of building.
Composer uses the dev versions and thus uses git clone to download the packages. The build script uses only stable packages, which will make Composer use the dist version. Some packages remove test and doc files from their dist files.
Composer contains all project related information, like a .gitignore. The build script previously assumed the person installing it didn't have git, so removed this file and other git related files like the .gitkeep files in app/cache and app/logs.
I any case, both the installer and composer always give you a working version of the Symfony Standard Edition.
At last, the build script was changed now the installer became the official way of installing. It'll now contain the git related files. On the other hand, it'll not contain the LICENSE file, UPGRADE-*.md files and README.md file. So in the end, we can say that the one installed by the installer is more usable, as it removes useless files.
Symfony2 Installer will downloaded it from the web site ( in this case: http://symfony.com/download?v=Symfony_Standard_Vendors_2.6.1.zip ).
To see the differences between symfony installer and the classic composer create-project is enough to take a look at both composer.lock: https://www.diffchecker.com/oig86oki
On the left the composer.lock generated after composer create-project, on the right symfony installer. It was obvious to everyone that Symfony2 downloaded from an archive could not have the lastest packages. So, do the update with composer update.
Again, on the left the composer.lock of composer create-project, on the right the new composer.lock after the update: https://www.diffchecker.com/lj5j2eap
As we expected. But in the vendor dir there are not the same number of file. Some folders are not there. Some folders with functional tests are not downloaded with symfony installer. You need to force composer to update all packages, or reinstall them.
Did you update installer as well with :
symfony self-update
or in windows :
php symfony.phar self-update
As stated here ?
That's perhaps one part of the answer.
Among differences, the installer seems to deal better with different symfony versions.

Should I download Laravel for every project?

I created a project with Laravel and downloaded from git via this command:
git clone -b develop git://github.com/laravel/laravel.git
The file size was about 21MB,
I want to know should I download Laravel for every project with this command?
What you have done is cloned the framework itself, which you should only do if you're going to fork and develop the Laravel core.
What you should do instead is use Composer to install your Laravel projects. You'll also be using Composer for other dependency-related actions in said projects (including autoload). This is the proper way of installing a fresh Laravel framework for developing a website:
composer create-project laravel/laravel --prefer-dist
http://laravel.com/docs/installation
Then, any future Laravel projects you create will be loaded from your Composer cache without needing to re-download.
The Composer package also sets up all your vendor-related .gitignore information and includes several other really useful management features. This is important, because you only want to keep your application-specific code under git version control, not the framework itself or any other dependencies. (Otherwise, your diffs and commits will get polluted with the dependencies' development changes.)
Once you've created a repository for your project, and installed Laravel with Composer, and created your first few commits (with some migrations, models, and controllers, for instance), cloning your project usually works something like this:
cd /clone-here
git clone /myproject # Location of current project
# /clone-here now has only the application-specific files from /myproject. It is
# still missing the framework itself and other dependencies.
composer install # Composer now looks at the dependencies in
# /clone-here/composer.json and installs them into /clone-here/vendor
# including the Laravel framework.
# Now the framework and other dependencies are good to go.
php artisan migrate # Laravel makes all your DB schemas from your migrations
php artisan db:seed # Seed your lovely new DB tables
It's really elegant and fun once you get used to it.
Edit:
See Sheikh's answer to save some time in the Composer install process!
Already Leng gave a nice answer.
Installing Laravel since version-4.1* via Laravel Installer is faster than composer
First, download the Laravel installer PHAR archive. For convenience,
rename the file to laravel and move it to /usr/local/bin. Once
installed, the simple laravel new command will create a fresh Laravel
installation in the directory you specify. For instance, laravel new
blog would create a directory named blog containing a fresh Laravel
installation with all dependencies installed. This method of
installation is much faster than installing via Composer.

Laravel 4 logic?

I recently downloaded a version of Laravel 4 and it was only 40kb. Laravel 3.2 was about 3.5mb, my questions are:
How can I use Laravel 4 completely offline?
I found out, Laravel 4 core codes was missing, Does it work cloud base or something like it!?
Which version do you recommend to use? Laravel 3.2 or Laravel 4? ( mostly for local developing )
thanks.
How did you installed Laravel? Using composer is as simple as:
composer create-project laravel/laravel your-project-name --prefer-dist
I use Laravel 4 for local development, and it works like a charm!
That's mainly because Laravel 4 uses composer to handle dependencies. What you downloaded wasn't exactly Laravel, but rather the structure for it. It's a preset project, with all default Laravel dependencies, so that all you have to do is run a command and download it all.
To use Laravel 4, you'll need to install composer. After you're done, open your command line, go to the folder where you saved the Laravel files you downloaded and, inside it, type: php composer install. This will download all the dependencies needed for the project; that means Laravel files and all of its own dependencies. It may take a while to install, and may seem to be stuck at Installing dependencies (including require-dev) for quite a long time, since there are lots of dependencies to be fetched, but that's normal. After it's done, you should see something like this:
Loading composer repositories with package information
Installing dependencies (including require-dev)
- Installing doctrine/lexer (dev-master bc0e1f0)
Downloading: 100%
...
- Installing laravel/framework (4.0.x-dev 733492c)
Downloading: 100%
...
Writing lock file
Generating autoload files
Generating optimized class loader
Now all you have to do is point the root of your webserver to the /public folder and start programming. If you ever feel you want to update your dependencies, simply run composer update.
Note: Remember to enable PHP's openssl extension, so composer can download the projects from github, and Apache's mod_rewrite, so Laravel pretty URLs work. If you're using Apache, that is.
NoteĀ²: Whenever you create a new command, controller, model, migration or seed, you'll have to type composer dump-autoload on your console, so composer knows how to autoload it.

Categories