How create package in Laravel 5? - php

php artisan workbench vendor/package --resources
command is not available in laravel 5, but how now create package in laravel 5 ?

Shameless self-promotion, but I've written a post about this called "Creating Laravel 5 packages for dummies" that explains how to create the package, how to put it on GitHub & Packagist and how to push changes/new versions afterwards.
If you're already familiar with creating packages in Laravel 4, the fastest solution I've found was to use this CLI tool.

The laravel workbench has been renamed in laravel 5 to "Package Development" in the documentation
http://laravel.com/docs/master/packages
Notice that there is no longer a workbench command and you need to create your own package structure, as the Laravel creator want to limit the dependency between created packages and the Laravel framework (#ref)
UPDATE: Laravel 5 is now stable and the illuminate/workbench package can be used in a laravel 5 application as I suggested in this post

In Laravel, these are some handy tricks I follow each time I need to create a Laravel package
Solution 1: Get a boilerplate template from https://github.com/cviebrock/laravel5-package-template, and put it under packages/ (follow the instruction in the repo)
Solution 2: Use a packager (with Laravel >= 5.5)
Install packager it as dev dependency > composer require jeroen-g/laravel-packager --dev (check instruction in the repo here)
create the package > composer require jeroen-g/laravel-packager --dev etc, see full tuto
then, we have a choice to keep the package in our project, or just remove it by rollingback composer.json
Hope this is a good update for Laravel lovers ;)

Related

problem with laravel 8 : Class 'Illuminate\Support\Facades\RateLimiter' not found [duplicate]

I've created my laravel project as follows:
laravel new my_app
This creates my project using laravel version 8. As I want to use Laravel 7, I modified composer.json:
"laravel/framework": "^7.0",
After that I run:
composer update
which ends with the error described (Class Illuminate\Support\Facades\RateLimiter not found )
In fact, that class doesn't exist in Support facade. Shouldn't downgrade process correct this?
No, this is from code in your application; specifically your App\Providers\RouteServiceProvider. Everything that isn't in vendor is considered your application and is not touched by any upgrade or downgrade. The laravel/laravel package only sets up your application skeleton for you. You can install Laravel 7 specifically with composer create-project --prefer-dist laravel/laravel:^7.0 yourproject; you can find the instructions in the install guide for Laravel 7.
Otherwise you will need to potentially copy the Service Providers from laravel/laravel version 7 into your application so you are not using providers from Laravel 8 as some things have changed and some new features were introduced. And there would be other changes as well.
Laravel 7.x Docs - Installation - via Composer Create-Project composer create-project

Laravel: How to modularize? [duplicate]

php artisan workbench vendor/package --resources
command is not available in laravel 5, but how now create package in laravel 5 ?
Shameless self-promotion, but I've written a post about this called "Creating Laravel 5 packages for dummies" that explains how to create the package, how to put it on GitHub & Packagist and how to push changes/new versions afterwards.
If you're already familiar with creating packages in Laravel 4, the fastest solution I've found was to use this CLI tool.
The laravel workbench has been renamed in laravel 5 to "Package Development" in the documentation
http://laravel.com/docs/master/packages
Notice that there is no longer a workbench command and you need to create your own package structure, as the Laravel creator want to limit the dependency between created packages and the Laravel framework (#ref)
UPDATE: Laravel 5 is now stable and the illuminate/workbench package can be used in a laravel 5 application as I suggested in this post
In Laravel, these are some handy tricks I follow each time I need to create a Laravel package
Solution 1: Get a boilerplate template from https://github.com/cviebrock/laravel5-package-template, and put it under packages/ (follow the instruction in the repo)
Solution 2: Use a packager (with Laravel >= 5.5)
Install packager it as dev dependency > composer require jeroen-g/laravel-packager --dev (check instruction in the repo here)
create the package > composer require jeroen-g/laravel-packager --dev etc, see full tuto
then, we have a choice to keep the package in our project, or just remove it by rollingback composer.json
Hope this is a good update for Laravel lovers ;)

Installing Laravel 4.1 with Laravel Installer

I'm trying to install Laravel 4.1 using the Laravel installer but the docs isn't very descriptive.
Can someone please give a step by step guide on how to do this? I'm completely new to Laravel and PHP frameworks as a whole.
I'm on a Windows 7 machine running WAMP 2.2.
This information/answer isn't quite up to date anymore. The instructions here will install the latest version which is no longer 4.1. For those still wanting to install Laravel 4.1 (despite 4.2+ being out), use the following command.
composer create-project laravel/laravel project_name 4.1
You could replace the 4.1 with 4.0 or 4.2 depending on your situation.
Laravel 4.1 is handy if you aren't in control of your PHP version and you're stuck back on 5.3.7
Laravel 4.2 requires PHP 5.4.
When upgrading a project to a newer version of Laravel, be sure to review the release notes
Installing Laravel means simply downloading Laravel Application bootstrap, which has to be placed in your project directory. That application has a composer.json file, which will, after you run composer install command, download all necessary dependencies (including core framework).
That is one way. Another preferred way is directly through:
composer create-project laravel/laravel project_name
In both cases, you need to have composer installed on your machine. Composer is a modern PHP package manager, which has a ton of benefits (autoloading, custom commands...).
There is really no need for two downvotes, especially when this guy was reading documentation, which he couldn't understand. We were all installing Laravel for the first time.
If you want install laravel via Laravel Installer use this method:
First, open up command line. then enter:
composer global require "laravel/installer=~1.1"
Now go to:
C:\Users\ {User Name} \AppData\Roaming\Composer\vendor
Copy and paste vendor in your destination folder.
Now in your destination folder hold the shift key down and press right click and in opened navigation menu click on "open command window here" then enter command below:
laravel new your_project_destination
Ex:
laravel new laraveltest

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 Package installation using composer

I need to know how to install packages in laravel 4.
I have downloaded a bundle from github, but executing the bundle, I see it is deprecated in Laravel 4. Can anyone please help me.
Just using packagist, you can go to packagist.org , after that just put the package name at require key in your composer.json on your laravel project, and that run this command , composer update or compose install
in example :
// composer.json
"require": {
// default value..
"intervention/image": "dev-master",
}
i hope this help
Laravel 4 now uses composer to install packages.
You can add new packages to laravel via a few options on composer. One is on the command line.
> composer require author/package
> dev-master
After issuing the require command it will ask you what version to use. then run composer update, add the PackageServiceProvider to your app/config/app.php
First and always if you plan to use composer in your work, learn the basics of it (what is composer.json,composer.lock...)
There is excellent video on Laracasts https://laracasts.com/lessons/you-must-use-composer
That way you can avoid problems and enjoy using this great package manager.
Next use composer dump(-autoload) command frequently and composer self-update.
If that bundle is deprecated in Laravel4 than it is deprecated and you can't use it ( unless author made some changes and adopt it for l4 )
Also bundle is a l3 specific type and in l4 we have packages.
Ok, you can't execute composer commands on windows command prompt. mac/linux terminal would do but if you insist on using windows then install this [https://www.cygwin.com/] so you could issue unix commands

Categories