I have created a package in Laravel 4 and uploaded it to github. How can I automate the unit testing using Jenkins CI as laravel package doesn't have vendor folder pused to github.
Related
I'm running my PHP application on Google Cloud App Engine Standard. After I deployed a new version of my app with a new composer package, I see that this new package was not installed during the deployment.
I deploy my app with gcloud app deploy. In the Cloud Console Debug tool, I can't find the package in the vendor folder. The package is successfully installed locally.
Is there a trick to update composer packages?
I had this problem too. Turns out this only works for '2nd generation run times'. In other words, your application will need to be PHP7.3. php5 applications will not process composer files.
I have a Laravel 5.1 application that I've built a couple of custom packages inside of (I follow this tutorial). These packages have no dependencies that didn't already exist in the root Laravel app.
My first question is, if I needed to add a dependency to the package that wasn't already in the root app, how would it get pulled into the root app? Running composer update or composer install from the root application does not pull them in. I understand that once I publish to GitHub and later pull the package into my app with Composer, that it's dependencies will pull in...but how do I do it while developing?
My next question is, how do I go about creating automated tests for this package? None of the tutorials I've found address this. Should the package be in it's own instance of Laravel with the tests inside of the tests directory?
To pull in dependencies for your own package, you will need to navigate to your package root (not your application root) and run the composer update and composer install commands from there. That should create a vendor directory local to your package which will contain all dependencies declared in your package's composer.json.
The same goes for testing - you can create a tests directory local to your package inside the larger Laravel app and run your tests from the package root. Just make sure to include your testing dependencies inside your package's composer.json.
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 ;)
I am just starting to learn about laravel packages, and started my first package.
My package requires some other packages installed in the vendor directory of my package via composer. When I come to do assets:publish my package, I need it to also assets:publish the vendor packages as well.
How do I go about automating this, or is it just a matter of guiding the user through publishing each package separately?
You can in Laravel call artisan inside of your application or package:
Artisan::call('assets:publish', array('--package' => 'Vendor/PackageName'));
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.