From a mesoscopic point of view the net number of particles going across a section with area $\delta y \delta z $ in a time $\tau$ and located about $x$ is given by
\begin{equation}
\Delta N(x,\tau) = \phi(x)\delta y \delta z v_0 \tau - \phi(x+\delta x)\delta y \delta z v_0 \tau
\end{equation}By expanding $\phi(x+\delta x) \approx \phi(x)+\partial_x \phi(x)\delta x$, we end up with the current density $j \equiv \Delta N/(\delta y \delta z\tau)$ giving:
\begin{equation}
j(x,t) = -\delta x \: v_0 \frac{\partial \phi}{\partial x}
\end{equation}Now, $v_0$ can be interpreted (up to some unimportant prefactor) as the ratio of the mean free path of the tracer particles $\lambda$ divided by the collision time $\tau$. We can end up rewriting the whole equation for the current as being:
\begin{equation}
j(x,t) = -D \frac{\partial \phi}{\partial x} = -\frac{\lambda^2}{\tau} \frac{\partial \phi}{\partial x}
\end{equation}
Now, in an inhomogeneous medium, the mean free path of tracer particles and the typical time between collisions will be both dependent on position $\lambda \rightarrow \lambda(x)$ and $\tau \rightarrow \tau(x)$, such that the diffusion coefficient of the tracer particles becomes effectively position dependent:
\begin{equation}
j(x,t) = -D(x) \frac{\partial \phi}{\partial x}
\end{equation}
Now, in crowded environments where there can be strong local inhomogeneities (not because of an external medium but because the tracer particles themselves have a stationary density profile), it is often the case that $D(x) = D(\phi(x))$, which often simplifies the derivation of general results on these problems.