Download the PHP package rockylars/faker without Composer

On this page you can find all versions of the php package rockylars/faker. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package faker

Introduction

Welcome to the world of single service testing with my favorite little project, Faker. It isn't much, but it will do what you need, simply create a class and make it extend Faker and implement the service's interface. I recommend creating a separate folder in your tests folder called "fake" to keep them from getting lost in your test files. I don't recommend using them in functional tests, just integration and unit tests.

History

Faker is something I've made through in class methods around March of 2023 while working at Future500 on a project for my former company, FinanceMatters/BondCenter, great guys in both of them. Over the next month more functions were added and due to the size of some classes, the methods were copied over to simplify the procedure. With PHP 8 turning throws into statements, the code was very compact, but some more testing revealed it needed to be a bit less compressed. Months passed and due to unfortunate circumstances out of my control, my partnership with the companies ended a 5 year long relationship. Luckily, the people there are really kind and also were sadly not that interested in the fun i've had with Faker, so they allowed me to keep it and distribute it as a package.

So here it is, the framework I've built because I highly disliked working with prophesizing and found mocking to be too convoluted and not simple enough. This simple abstract class allows you to build fake classes to your heart's content, without PHPStan ever yelling at you. They are made to be as simple as possible with a later addition of some getAllCalls.. methods to not technically require a new check whenever you add a new method.

Usage

For unit tests, I recommend faking everything, but some classes shouldn't be faked and instead be kept as half active. Such half active classes are for example a fake clock with a updateTime() method inside.

For integration tests, only fake what you need to fake, don't fake things like the connection when you are testing a repository, but you can then use fake things like a Guzzle client. On that note, don't actually use Faker for your logger, you will have many calls to logger but will already be testing the output and don't care much for a duplicate input. For a logger, it's best to just array collect it and "fake" it like that, other classes like that where you don't own the deeper layers should get the same array collection treatment. However, with all that said, you do you.

Future

I will add a method that adds a count check between the amount of responses set up and the amount of calls done, similar to something Mockery offers. This is rather useful of course if you have a lot of responses or set up data but missed that you didn't actually see anything go in, happens when you have a lot of fake classes set up for one service.

Examples

Keep in mind that if you use expectException and expectExceptionMessage instead of expectThrowable you should use the following code to wrap your call as those will silently ignore the asserts below it otherwise.

Set up the project for commits on Linux

  1. Have Docker functional, you don't need an account for this.
  2. Have a GitHub account (obviously) for commits.
  3. Get an SSH token set up (preferably id_ed25519) and hooked up to your GitHub account.
    • If not, you won't be able to pull/push anything properly.
  4. Get the project downloaded and cd into the folder.
    • If you plan to make any PR's and don't have rights, make a fork first, grab that, and then attempt to merge PR's of that in.
  5. Make sure that running git config --global --list and git config --list both show user.email=YOUR_GITHUB_EMAIL and user.name=YOUR_GITHUB_USER_NAME.
    • If not, here's the steps to fix it:
    • Set the value for the project and unset the one for local, otherwise set it for local only.
    • Your commits won't link to an account if this is not done.
  6. Make sure that running groups shows docker in it.
    • If not, here's the steps to fix it:
    • run sudo usermod -aG docker $USER and then reboot your PC.
    • You won't be able to run the needed Docker commands if this is not done.
  7. Make sure that running ls -la ~/.composer shows your user instead of root for ..
    • If not, here's the steps to fix it:
    • Run sudo chown -R $USER:$USER ~/.composer.
    • You won't be able to store library authentication and Composer cache if this is not done.
  8. Have the make extension installed.
  9. Run make setup and you're done.

[Optional] Get access to private repositories you have access to on GitHub:

  1. Generate an access token in GitHub with just the Repo permissions.
  2. Run make composer and add config --global github-oauth.github.com YOUR_GENERATED_TOKEN.

All versions of faker with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
thecodingmachine/safe Version >=2.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package rockylars/faker contains the following files

Loading the files please wait ....