Use the PHP libsodium extension or the PHP encryption library. Both are high-quality libraries that provide well-documented functions that allow you to do what you need. They also includes automatic integrity check (this is crucial!), and their operations are protected against timing attacks.
AES256-CTR provides only unauthenticated encryption, which is almost never what you want. You need authenticated encryption.
The libsodium extension has the advantage of being faster in most cases, but it depends on an extension module written in C, so it might not be available everywhere. php-encryption is slower, but it only uses PHP’s built-in OpenSSL binding, so it runs everywhere.
Note that nonces must never be loaded from disk and then used for encryption. It’s way too easy to have a collision that way. Instead, you should generate a fresh encryption key from a master key each time your program starts (using a KDF and some secure random bytes.)